Hi,
I have built a form for a report. I am in process of validating the fields on the form before generating my report. I have included a snippet of the code so you can see what I am trying to do.
If (txtIssue <> "") Then
sWhere = sWhere & " AND [AD_MAGAZINE_ISSUE] = " & txtIssue
End If
If (txtMagPage <> "") Then
sWhere = sWhere & " AND [AD_MAGAZINE_PAGE] = " & txtMagPage
End If
If (SalesRep <> "") Then
sWhere = sWhere & " AND [AD_MAGAZINE_SALESREP] = " & SalesRep
End If
If (BegSalesDate <> "" And IsNull(EndSalesDate)) Then
Forms!frmReportSelection!EndSalesDate.SetFocus
bOK = MsgBox("Enter value for end sales date.", vbOKOnly, "End Sales Date Error")
End If
Please take notice of the SetFocus command at the bottom of the snippet. It does not seem to be wroking for me. The form does not place focus in the EndSalesDate field. I do get the MsgBox but no focus to the specified field.
Can someone tell me what I am doing wrong here? I am very new to VB and I am still learning.
Also I also wonder where I should pass control once user does get focus and enters the EndSalesDate. I still would need to validate it. Would I use the Resume statement and pass control to a previous line? Maybe preceeding the BegSalesDate/EndSalesDate validation immediately.
Your help would be appreciated.
Thanks in advance.
...TheB
I have built a form for a report. I am in process of validating the fields on the form before generating my report. I have included a snippet of the code so you can see what I am trying to do.
If (txtIssue <> "") Then
sWhere = sWhere & " AND [AD_MAGAZINE_ISSUE] = " & txtIssue
End If
If (txtMagPage <> "") Then
sWhere = sWhere & " AND [AD_MAGAZINE_PAGE] = " & txtMagPage
End If
If (SalesRep <> "") Then
sWhere = sWhere & " AND [AD_MAGAZINE_SALESREP] = " & SalesRep
End If
If (BegSalesDate <> "" And IsNull(EndSalesDate)) Then
Forms!frmReportSelection!EndSalesDate.SetFocus
bOK = MsgBox("Enter value for end sales date.", vbOKOnly, "End Sales Date Error")
End If
Please take notice of the SetFocus command at the bottom of the snippet. It does not seem to be wroking for me. The form does not place focus in the EndSalesDate field. I do get the MsgBox but no focus to the specified field.
Can someone tell me what I am doing wrong here? I am very new to VB and I am still learning.
Also I also wonder where I should pass control once user does get focus and enters the EndSalesDate. I still would need to validate it. Would I use the Resume statement and pass control to a previous line? Maybe preceeding the BegSalesDate/EndSalesDate validation immediately.
Your help would be appreciated.
Thanks in advance.
...TheB