Docmd.OpenForm WHERE condition trouble

evictme

Registered User.
Local time
Today, 05:30
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.
 
Hi. It looks good. What is happening instead? Are you getting any error messages?
 
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.
 
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?
 
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:
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?
 
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
 
It looks like it is not picking up the filter or the value from the subform
 
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.
 
Are you sure that's correct? Try:

DoCmd.OpenForm "AuditClicksUsers", acFormDS, , "[User]=" & Me.Logged_In
 
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
 
Is your Logged_In domain full?
Is the user field numeric or string?
 
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:
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

Back
Top Bottom