Docmd.OpenForm WHERE condition trouble (2 Viewers)

evictme

Registered User.
Local time
Today, 03:12
Joined
May 18, 2011
Messages
168
So you need to at least surround it with single quotes.?
Are any of the names likely to have a single quote in them?

try
Code:
DoCmd.OpenForm "AuditClicksUsers", acFormDS, , "[User]='" & Me.Logged_In & "'"
This is the code I am using currently, does the same thing. None of the usernames have single quotes around them
 

onur_can

Active member
Local time
Today, 01:12
Joined
Oct 4, 2015
Messages
180
What are the consequences? What error do you get
 

evictme

Registered User.
Local time
Today, 03:12
Joined
May 18, 2011
Messages
168
What are the consequences? What error do you get
No error. It gives me the prompt i posted earlier, the prompt for entering the parameter value using the Logged_in value as the name of the prompt. If I type the value in the parameter box it will do what I need but I need it to simply go directly to the form with filtered by the user name.
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:12
Joined
Sep 21, 2011
Messages
14,319
You are no longer using single quotes. :(, hence access thinks the contents is a variable name?
 

evictme

Registered User.
Local time
Today, 03:12
Joined
May 18, 2011
Messages
168
You are no longer using single quotes. :(, hence access thinks the contents is a variable name?
This is what i am using:
DoCmd.OpenForm "AuditClicksUsers", acFormDS, , "[User]=’" & Me.Logged_In & “‘“, , acWindowNormal

This is the result, “arivera” is a user on the list of Logged_in:
1586977218154.png
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:12
Joined
Sep 21, 2011
Messages
14,319
It does not help when you post code without code tags as ' and " are too close together.
The last suggestion was NOT using single quotes?

Having copied and pasted your code within code tags, you do not appear to be using single quote, but something similar at the start of the variable, which can be seen in the prompt.?

Code:
DoCmd.OpenForm "AuditClicksUsers", acFormDS, , "[User]=’" & Me.Logged_In & “‘“, , acWindowNormal

this works for me
Code:
DoCmd.OpenForm "Form1", acFormDS, , "[Field2]='" & tt & "'"
also
Code:
DoCmd.OpenForm "Form1", acFormDS, , "[Field2]=""" & tt & """"
so why not you?
 

evictme

Registered User.
Local time
Today, 03:12
Joined
May 18, 2011
Messages
168
It does not help when you post code without code tags as ' and " are too close together.
The last suggestion was NOT using single quotes?

Having copied and pasted your code within code tags, you do not appear to be using single quote, but something similar at the start of the variable, which can be seen in the prompt.?

Code:
DoCmd.OpenForm "AuditClicksUsers", acFormDS, , "[User]=’" & Me.Logged_In & “‘“, , acWindowNormal

this works for me
Code:
DoCmd.OpenForm "Form1", acFormDS, , "[Field2]='" & tt & "'"
also
Code:
DoCmd.OpenForm "Form1", acFormDS, , "[Field2]=""" & tt & """"
so why not you?
I’ve tried your suggestions. They only add single or double quotes to the front of the name of the prompt box.
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:12
Joined
Sep 21, 2011
Messages
14,319
Copy and paste my code exactly as it is.

Code:
DoCmd.OpenForm "AuditClicksUsers", acFormDS, , "[User]='" & Me.Logged_In & "'", , acWindowNormal
 

evictme

Registered User.
Local time
Today, 03:12
Joined
May 18, 2011
Messages
168
Copy and paste my code exactly as it is.

Code:
DoCmd.OpenForm "AuditClicksUsers", acFormDS, , "[User]='" & Me.Logged_In & "'", , acWindowNormal
Works perfectly. WTH did i miss? I thought I was using the exact code, where did i go wrong?
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:12
Joined
Sep 21, 2011
Messages
14,319
Look closely at what you *thought* were single quotes in post 27

Not sure of your language, but they were not single quotes to me?
 

evictme

Registered User.
Local time
Today, 03:12
Joined
May 18, 2011
Messages
168
Look closely at what you *thought* were single quotes in post 27

Not sure of your language, but they were not single quotes to me?
My language is English. I guess I missed that. I am working remotely on an ipad and the text size is smaller than im used to. Thanks for your help, i appreciate it very much.
 

Users who are viewing this thread

Top Bottom