Docmd.OpenForm WHERE condition trouble (1 Viewer)

evictme

Registered User.
Local time
Today, 04:19
Joined
May 18, 2011
Messages
168
Hello all,

I am trying to run this code in the OnClick command of a field on a sub-form. The subform is in Continuous and displays records that are available in realtime.

This is the code:

DoCmd.OpenForm "AuditClicksUsers", acFormDS, , “User = ‘“ & Me.Logged_In.Value & “‘“, , , acWindowNormal

The AuditClicksUsers form is based on a query that is based on a Union Query.

Id like to open the form filtered by the value I click or double-click on, what am i not seeing?

Any help would be greatly appreciated.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:19
Joined
Oct 29, 2018
Messages
21,358
Hi. It looks good. What is happening instead? Are you getting any error messages?
 

evictme

Registered User.
Local time
Today, 04:19
Joined
May 18, 2011
Messages
168
Hi. It looks good. What is happening instead? Are you getting any error messages?
It opens the form but does not show any records. It is filtered but there are no corresponding records.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:19
Joined
Oct 29, 2018
Messages
21,358
It opens the form but does not show any records. It is filtered but there are no corresponding records.
Is the filter correct? If so, are sure there are matching records?
 

evictme

Registered User.
Local time
Today, 04:19
Joined
May 18, 2011
Messages
168
It doesnt display the filter term and Yes, there are a lot of records. Maybe I am not including the filter correctly? Should I be using the FILTER condition instead?
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 02:19
Joined
Oct 29, 2018
Messages
21,358
It doesnt display the filter term and Yes, there are a lot of records. Maybe I am not including the filter correctly? Should I be using the FILTER condition instead?
No, the WhereCondition is fine. Go to the Form design view and add a Textbox to show its Filter. For example:

=[Filter]

Then, run your code and let us know what you see when the form opens again. Does it look correct?
 

evictme

Registered User.
Local time
Today, 04:19
Joined
May 18, 2011
Messages
168
No, the WhereCondition is fine. Go to the Form design view and add a Textbox to show its Filter. For example:

=[Filter]

Then, run your code and let us know what you see when the form opens again. Does it look correct?
1586901125010.png
 

evictme

Registered User.
Local time
Today, 04:19
Joined
May 18, 2011
Messages
168
It looks like it is not picking up the filter or the value from the subform
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:19
Joined
Oct 29, 2018
Messages
21,358
It looks like it is not picking up the filter or the value from the subform
Right, looks that way. Is the Data Entry property of the form set to Yes? If so, try setting it to No.
 

zeroaccess

Active member
Local time
Today, 04:19
Joined
Jan 30, 2020
Messages
671
Are you sure that's correct? Try:

DoCmd.OpenForm "AuditClicksUsers", acFormDS, , "[User]=" & Me.Logged_In
 

evictme

Registered User.
Local time
Today, 04:19
Joined
May 18, 2011
Messages
168
Are you sure that's correct? Try:

DoCmd.OpenForm "AuditClicksUsers", acFormDS, , "[User]=" & Me.Logged_In
Thanks ZeroAccess, it looks like this gets me closer. When I run the code (click on the field) it gives me a prompt to enter the parameter and the NAME of the prompt is the name represented by the Me.logged_in (see below). It looks like I need to add something that will just use the value AS the parameter value instead of prompting. Any suggestions?

1586972365118.png
 

onur_can

Active member
Local time
Today, 02:19
Joined
Oct 4, 2015
Messages
180
Is your Logged_In domain full?
Is the user field numeric or string?
 

onur_can

Active member
Local time
Today, 02:19
Joined
Oct 4, 2015
Messages
180
There is a value in the Logged_IN field when you open the form, right?

Code:
DoCmd.OpenForm "AuditClicksUsers", acFormDS, , "User = '" & Logged_In & "'", acFormEdit
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 09:19
Joined
Sep 21, 2011
Messages
14,050
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 & "'"
 

Users who are viewing this thread

Top Bottom