ChuckRobert
Board Regular
- Joined
- Feb 26, 2009
- Messages
- 64
When logging into my program, user information is captured in a query. I am trying to access that with a DLookup as the form loads so I can use those values to determine which buttons and text boxes are to be enabled. The problem is that the form loads before the DLookup is captured by the form load event. Here is a sample of my code:
If I close and reopen the form again, the DLookup properly confiures by controls I want enabled, or disabled. Can anyone offer a suggestion?
Code:
[COLOR=black][FONT=Times New Roman]Option Compare Database<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]Option Explicit<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]Private Sub Form_Load()<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]Dim rank As String<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]Dim shift As Integer<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]Dim assign As String<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]rank = DLookup("[LastOfLogIn_Rank]", "qry_User")<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]shift = DLookup("[LastOfLogIn_Shift]", "qry_User")<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]assign = DLookup("[LastOfLogIn_Assignment]", "qry_User")<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]‘testing values onto temp text boxes on the form. Displays previous, not currrent values in these test boxes.[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]Me!txtRank = rank<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]Me!txtshift = shift<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]Me!txtAssign = assign<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]If ((shift = "1") And (rank = "Cook") And (assign = "Kitchen")) Then<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]Me!txtOne.Enabled = False<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]Me!btnOne.Enabled = True<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]End If<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Times New Roman]End Sub<o:p></o:p>[/FONT][/COLOR]
If I close and reopen the form again, the DLookup properly confiures by controls I want enabled, or disabled. Can anyone offer a suggestion?