Hi I am trying to autogenerate reports based on answers in comboboxes.
I am trying to check if the combobox is empty but not having success... Here is my code both address and username are comboboxes...
Option Compare Database
Option Explicit
Private Sub generateReport_Click()
Dim address As String
Dim UserName As String
address = Me.custAddress
UserName = Me.UserName
If Len(address.Value Or UserName.Value) > 0 Then
MsgBox "Please Choose a Form Name!", vbOKOnly
Me.custAddress.SetFocus
End If
Debug.Print (address)
DoCmd.OpenReport "Generation", acViewPreview, address & UserName, _
WhereCondition:="AddressLine1 = '" & address & UserName & "'"
End Sub
Edited version:
Option Compare Database
Option Explicit
Private Sub generateReport_Click()
If custAddress.Value = vbNullString Or UserName.Value = vbNullString Then
Debug.Print ("fail")
Else
DoCmd.OpenReport "Generation", acViewPreview, Me.custAddress & Me.UserName, _
WhereCondition:="AddressLine1 = '" & Me.custAddress & Me.UserName & "'"
End If
End Sub