im new at vba and i have no idea why this coding is not working. it's suppose to let me search for a name but i get an error. It's a simple popup page that has a field i can type the "payer" name and search from the form "LogTxTable". When i type the name i want to search for and click ok, i get a Compile error: sub or function not defired.
and it also highlights private sub cmdSome_Click() yellow and also highlights IsNothing in blue. I copied this coding from other database and pretty much changed the names. Is there something wrong with decarling? any kind of help would be appreciated. thank you.
and it also highlights private sub cmdSome_Click() yellow and also highlights IsNothing in blue. I copied this coding from other database and pretty much changed the names. Is there something wrong with decarling? any kind of help would be appreciated. thank you.
Code:
Option Compare Database
Option Explicit
Private Sub cmdCancel_Click()
DoCmd.Close acForm, Me.Name
End Sub
Private Sub cmdSome_Click()
Dim varWhere As Variant
'set and error trap
On Error GoTo cmdSome_Err
'Initialize to Null
varWhere = Null
'If specified Payer
If Not IsNothing(Me.txtPayer) Then
varWhere = "[Payer] LIKE '" & Me.txtPayer & "*'"
End If
If IsNothing(varWhere) Then
MsgBox "You must enter at least one search criteria.", vbInformation, gstrAppTitle
Exit Sub
End If
'close the form if it's open
If IsFormLoaded("frmLogTxTable") Then
If vbYes = MsgBox("The Members window is already open. This search " & "will cancel any pending edits in that window, close it, and " & "attempt to reopen with the criteria you specified." & vbCrLf & vbCrLf & "Are you sure you want to proceed?", vbQuestion + vbYesNo + vbDefaultButton2, gstrAppTitle) Then
Form_frmLogTxTable.cmdCancel_Click
Else
Exit Sub
End If
End If
'open frmLogTxTable
DoCmd.OpenForm FormName:="frmLogTxTable", whereCondition:=varWhere, WindowMode:=acHidden
If Forms!frmLogTxTable.RecordsetClone.RecordCount = 0 Then
'no orders for selected customers
MsgBox "There are no members that match the selected criteria.", vbInformation, gstrAppTitle
DoCmd.Close acForm, "frmLogTxTable"
Exit Sub
Else
Forms!frmLogTxTable.Visible = True
End If
DoCmd.Close acForm, Me.Name
cmdSome_Exit:
Exit Sub
cmdSome_Err:
ErrorLog Me.Name & "_cmdSome", Err, Error
MsgBox "Unexpected error: " & Err & ", " & Error, vbCritical, gstrAppTitle
Resume cmdSome_Exit
End Sub
Last edited by a moderator: