N
NeoFax99
I am trying to use an OnCurrent event to do a dlookup to check an item.
Then show a subform based on the dlookup item. The problem is the
dlookup only returns the first items value and not the current items.
below is the code:
Private Sub Form_Current()
Dim formNo As String
Forms!frmAssett.Form3215Information.Visible = False
Forms!frmAssett.Form9Information.Visible = False
Forms!frmAssett.Form332Information.Visible = False
formNo = DLookup("FormNo", "tblAssett")
MsgBox formNo, vbInformation
If formNo = "1" Then
Forms!frmAssett.Form3215Information.Visible = False
Forms!frmAssett.Form9Information.Visible = True
Forms!frmAssett.Form332Information.Visible = False
ElseIf formNo = "2" Then
Forms!frmAssett.Form3215Information.Visible = False
Forms!frmAssett.Form9Information.Visible = False
Forms!frmAssett.Form332Information.Visible = True
ElseIf formNo = "3" Then
Forms!frmAssett.Form3215Information.Visible = True
Forms!frmAssett.Form9Information.Visible = False
Forms!frmAssett.Form332Information.Visible = False
End If
End Sub
I added in the MsgBox just to see what dlookup shows as the value.
Then show a subform based on the dlookup item. The problem is the
dlookup only returns the first items value and not the current items.
below is the code:
Private Sub Form_Current()
Dim formNo As String
Forms!frmAssett.Form3215Information.Visible = False
Forms!frmAssett.Form9Information.Visible = False
Forms!frmAssett.Form332Information.Visible = False
formNo = DLookup("FormNo", "tblAssett")
MsgBox formNo, vbInformation
If formNo = "1" Then
Forms!frmAssett.Form3215Information.Visible = False
Forms!frmAssett.Form9Information.Visible = True
Forms!frmAssett.Form332Information.Visible = False
ElseIf formNo = "2" Then
Forms!frmAssett.Form3215Information.Visible = False
Forms!frmAssett.Form9Information.Visible = False
Forms!frmAssett.Form332Information.Visible = True
ElseIf formNo = "3" Then
Forms!frmAssett.Form3215Information.Visible = True
Forms!frmAssett.Form9Information.Visible = False
Forms!frmAssett.Form332Information.Visible = False
End If
End Sub
I added in the MsgBox just to see what dlookup shows as the value.