| 
        
        
        
       
        
        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
 |