Opening bound form via macro or docmd

mdnuts

Registered User.
Local time
Yesterday, 19:08
Joined
May 28, 2014
Messages
131
I have a bound form that normally is opened via macro. Very straight forward just has the following in the where.
Code:
 [userID]=[Forms]![Home]![txtSelectUser]
I'm trying to open the same form via doCmd.

Code:
DoCmd.OpenForm "frmUserInformation", , , "UserID=" & Me.txtProblemID
I've msgbox'd the txtProblemID and the correct ID is being passed. Where I fall into an error is on the frmUserInformation's onLoad event which uses the ID form the frmUserInformation.txtUserID box. The error I get is "Syntax error (missing operator in query expression '[fldUserID]='."

Code:
strEndMonth = DLookup("fldDateExpiration", "qryUserExpirationDate", "[fldUserID]=" & Me.txtUserID)
What I've narrowed it to is the timing between the docmd.openform and the onload of the form. I've tried changing the onload to be on activate - and it just opens empty.

Any ideas how to get the docmd to open the form correctly before the onload tries to fire?
 
Have you tried using the On Current event of frmUserInformation's
 
Same error - missing expression, which works fine doing a macro open.
 
Perhaps you could parse the required value using the OpenArgs argument of OpenForm and then refer to its value in your OnLoad event
 
hmm, i haven't used that yet. let me research into it.
 
been giving it some thought. I'm thinking the result would be the same. I could just as easily assign a dim to what's passed via the txtUserID.

What I probably need to do is unbound the form and set each location that calls it to do it via vba instead of macro.
 

Users who are viewing this thread

Back
Top Bottom