For the life of me, I cannot get this function to work. It either gives me "Invalid use of Null" or "You canceled this operation... blah blah" every time. I am just going to lay out what I'm trying to do and hopefully somebody can point me in the right direction. BTW, I am using Access 2003:
1. I have a form called: frmLogAccepted
2. On that form is a textbox called: txtProjectNumber
3. There is a table in the databased called: tblMaintTrack
4. tblMaintTrack has a ProjectNumber field as well
5. I want the user to be able to enter a project number into frmLogAccepted's textbox called txtProjectNumber, then on the "lost focus" event of the textbox DLookup will be used to see if the ProjectNumber entered has a matching ProjectNumber record in tblMaintTrack
6. If the corresponding project number IS found, then I want it to populate txtIDMT on frmLogAccepted with the IDMT value (long integer) that is found in the record with the matching ProjectNumber in tblMaintTrack
7. In plain English, "Select IDMT From tblMaintTrack Where tblMaintTrack.ProjectNumber = frmLogAccepted.txtProjectNumber"
8. The following is what I have so far. I've driven myself to madness trying to figure this stupid thing out:
Thanks in advance for any help you may be able to provide.
1. I have a form called: frmLogAccepted
2. On that form is a textbox called: txtProjectNumber
3. There is a table in the databased called: tblMaintTrack
4. tblMaintTrack has a ProjectNumber field as well
5. I want the user to be able to enter a project number into frmLogAccepted's textbox called txtProjectNumber, then on the "lost focus" event of the textbox DLookup will be used to see if the ProjectNumber entered has a matching ProjectNumber record in tblMaintTrack
6. If the corresponding project number IS found, then I want it to populate txtIDMT on frmLogAccepted with the IDMT value (long integer) that is found in the record with the matching ProjectNumber in tblMaintTrack
7. In plain English, "Select IDMT From tblMaintTrack Where tblMaintTrack.ProjectNumber = frmLogAccepted.txtProjectNumber"
8. The following is what I have so far. I've driven myself to madness trying to figure this stupid thing out:
Code:
Private Sub txtProjectNumber_LostFocus()
Me.txtIDMT = DLookup("[IDMT]", "tblMaintTrack", "[ProjectNumber]=" & Forms![frmLogAccepted]![txtProjectNumber])
Me.Refresh
End Sub
Thanks in advance for any help you may be able to provide.