Ask Experts Questions for FREE Help !
Ask
    mrsgwen90's Avatar
    mrsgwen90 Posts: 10, Reputation: 1
    New Member
     
    #1

    Oct 11, 2007, 07:24 AM
    have a form in Access with some VB 6.0 code
    I have a form in Access. On the form I have a combo box called "cboPaymentMethod" and in the combo box there are 3 choices: cash, check, and free. I also have a text box called "CheckNum". Once the user picks "check" from the combo box they will tabl on through and when they get to the CheckNum field they are suppose to enter the check no. So to ensure that the user will enter the check no. I want to enter some code that will prompt the user to enter a check number if they have chose "check" from the dropdown.

    Algorithm: If check is chosen in the PaymentMethod combo box
    and the check num field is null
    prompt user to go back and enter a check number.

    Here is my code. Please look and see what I'm doing wrong or maybe I have the code in the wrong place.

    Private Sub PrintRec_Click()
    On Error Go to Err_PrintRec_Click

    Dim rstTrans As New ADODB.Recordset
    Dim fld As ADODB.Field
    Dim strField As String
    Dim curCount As Currency


    If Me.cboPaymentMethod = "Check" And CheckNum.Text = "" Then 'Check number not entered
    MsgBox "You must enter a check no."
    CheckNum.SetFocus
    End If

    rstTrans.Open "dbo_tbl_Transactions", CurrentProject.Connection, adOpenKeyset, adLockOptimistic

    If IsNull(Me.TempTransNumID.value) Then
    'this is new record
    rstTrans.AddNew
    Else
    'to stay on the record that was just inserted for editing
    rstTrans.Find ("TransNumID=" + Str$(Me.TempTransNumID))
    End If


    rstTrans!TransDate = Me.TransDate
    rstTrans!CustomerName = Me.CustomerName
    rstTrans!VehType = Me.VehType
    rstTrans!TktType = Me.TktType
    rstTrans!Auth_By = Me.AuthBy
    rstTrans!Quantity = Me.Quantity
    rstTrans!SHtkt1 = Me.SHtkt1
    rstTrans!SHtkt2 = Me.SHtkt2
    rstTrans!HRtkt1 = Me.HRtkt1
    rstTrans!HRtkt2 = Me.HRtkt2
    rstTrans!TransPayAmt = Me.TransPayAmt
    rstTrans!PaymentType = Me.txtPaymentType
    rstTrans!PaymentMethod = Me.cboPaymentMethod
    rstTrans!CheckNum = Me.CheckNum
    rstTrans!TransReceiptMemo = Me.TransReceiptMemo
    rstTrans!TransEntryTime = Now()
    rstTrans!TransEntryUserID = appUser

    rstTrans.Update
    'this was a new record so update the form value of TransNumID for edit
    If IsNull(rstTrans!TransNumID.value) <> True Then
    Me.TempTransNumID = rstTrans!TransNumID.value
    End If


    whereClause = "NewQryShuttleHandiRideReceipt.TransNumID" & " = " & rstTrans!TransNumID

    DoCmd.OpenReport "RptShuttle HandiRide Receipt", acViewNormal, , whereClause

    rstTrans.Close

    Set rstTrans = Nothing
    Me.cmdAddRec.Enabled = True

    Exit_PrintRec_Click:
    MsgBox "Record Successfully Saved! Printing Receipt."
    Exit Sub

    Err_PrintRec_Click:
    MsgBox Err.Description
    Resume Exit_PrintRec_Click

    End Sub
    fdcusa's Avatar
    fdcusa Posts: 3, Reputation: 1
    New Member
     
    #2

    Dec 13, 2007, 10:24 PM
    If Me.cboPaymentMethod = "Check" And Me.CheckNum = "" Then
    'Check number not entered
    MsgBox "You must enter a check no."
    CheckNum.SetFocus
    Goto Exit_PrintRec_Click
    End If

    ...

    then below:

    MsgBox "Record Successfully Saved! Printing Receipt."

    Exit_PrintRec_Click:

    Exit Sub

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Building Code for Bathtub Access Panel? [ 5 Answers ]

Does there have to be an access panel "cover" -- the actual panel -- for the bathtub, or can that area -- pipes and all, the underneath of the bathtub, etc. -- all be left open? Is there typically a building code about that? Thank you.

Slope-intercept form and standard form. [ 1 Answers ]

how do I find the slope intercept form of (-7,-4); m=-1/2 and the standard form of (-5,2);m=2/5 (16/3,-9);m=0 (3,-3);m=-3/8

Can you file more than one w2 form on one nys tax form or do you need additional forms? [ 1 Answers ]

We live in nys and my friend has had 3 different jobs throughout the year. Does he file all w2's on one form or have a form for each?

Can't access pop3, Pop3 access not working from my computer [ 1 Answers ]

I have XP SP 2 - Its been about a week since any of my pop3 accounts have worked (Gawab, Gmail, Spymac, Toughguy). The error messages I am receiving on all of my pop3 accounts are similar to : The host 'pop.gawab.com' could not be found. Please verify that you have entered the server name...


View more questions Search