Opening a form with a where condition does not work

tevans9104

New member
Local time
Today, 18:04
Joined
Aug 30, 2007
Messages
1
I need some help! I am trying to open a form with a DoCmd.Openform "frmname",,,strcriteria. The strcriteria is DIM as string with a value of strcriteria = "[txtUserId]=" & Me.txtLoginName

The txtUserId is the bound field on the frmname and the txtLoginName is the combo box selection on this form that will call the frmname on my cmdSave action code. The prompt I receive before the openform action is asking for a parameter value for the value of the txtLoginName from the screen. If I enter in the same value that I just entered into the combo box it accepts the value and performs the action and opens the form with the record that I just save like it is suppose to do. I would like to eliminate the prompt for the parameter value and I just can't seem to eliminate it with enclosing the Me.txtloginname field. I am not able to compare the value of txtLoginName and access seems to be looking at this like a parameter instead of comparing the value of the two strings. txtUserid is defined as a string.

Please let me know what I am doing wrong or please give me a work around. Any help you can give me would be greatly appreciated.

Tom
 
are you positive that the txtloginname is the exact name of the field on the form?
 
Have you tried
Code:
strcriteria = "[txtUserId]=[B]'[/B]" & Me.txtLoginName[B] & "'"[/B]
The line as written
Code:
strcriteria = "[txtUserId]=" & Me.txtLoginName
is looking for a number, as there are no quotes around the last part
 
Have you tried
Code:
strcriteria = "[txtUserId]=[B]'[/B]" & Me.txtLoginName[B] & "'"[/B]
The line as written
Code:
strcriteria = "[txtUserId]=" & Me.txtLoginName
is looking for a number, as there are no quotes around the last part

good catch
 
Heh, not as dumb as I look. ;)
 

Users who are viewing this thread

Back
Top Bottom