yameen2011
Registered User.
- Local time
- Today, 18:15
- Joined
- Jan 19, 2013
- Messages
- 59
Helo friends i have an issue using dlookup function.i want a condtional dlookup. i the condition is true then dlookup works if condition false then stop.
i have a tbl_accounts fields are
GL_code, Description, Ac_Descp, GL_type,
and other tbl_transaction both tbl have one 2 many relationship and a form transaction that makes transaction in transaction tbl against gl codes.
on the form i have a field GL_code, tran_Type, Amt, TDate, Narrative
where against GL_code a description field is also there that lookup values from tbl_accounts. dlookup is working fine. but here i want that before dlookup function take a action. it will check GL_type in accounts tbl that either th GL_code is "S" type or "C" if the GL code type is S then msg box will apear that " not allowed" and dlookup stop and exit. if GL type is C then dlookup works. i have also attached screen shot of my tbl_accounts and Vb code is:
i have a tbl_accounts fields are
GL_code, Description, Ac_Descp, GL_type,
and other tbl_transaction both tbl have one 2 many relationship and a form transaction that makes transaction in transaction tbl against gl codes.
on the form i have a field GL_code, tran_Type, Amt, TDate, Narrative
where against GL_code a description field is also there that lookup values from tbl_accounts. dlookup is working fine. but here i want that before dlookup function take a action. it will check GL_type in accounts tbl that either th GL_code is "S" type or "C" if the GL code type is S then msg box will apear that " not allowed" and dlookup stop and exit. if GL type is C then dlookup works. i have also attached screen shot of my tbl_accounts and Vb code is:
PHP:
Private Sub GL_Code_AfterUpdate()
If IsNull(DLookup("GL_Code", "tbl_Accounts", "GL_Code=" & Forms!GL30!GL_Code)) Then
MsgBox "Invalid GL Code. No record exist.", vbCritical, "Error"
MsgBox "Please enter valid GL Code.", vbCritical, "Error"
DoCmd.GoToControl ("Trn_Type")
DoCmd.GoToControl ("GL_Code")
End If
Desc = DLookup("GL_Desc", "tbl_Accounts", "GL_Code=" & GL_Code)
End Sub
Private Sub GL_Code_BeforeUpdate(Cancel As Integer)
If IsNull(Me!GL_Code) Then
MsgBox "Value for this field must be entered first.", vbInformation, "Alert"
Cancel = True
End If
End Sub
Private Sub GL_Code_LostFocus()
If IsNull(Me!GL_Code) Then
MsgBox "GL Code can not be Null.", vbInformation, "Alert"
Cancel = True
DoCmd.GoToControl ("Trn_Type")
DoCmd.GoToControl ("GL_Code")
End If
End Sub