DoCmd Where Condition

I have a report and on the onclick event of a texbox in the report I am trying to open a form and for it to filter on the Admin Name.

The Admin Name is displayed on the report, however when I click on the text box pop-up appears 'AdminName' and a input box, if I typed in the name the form opens blank, what am I doing wrong?

Private Sub Cleansed_Click()
Dim AdminName As String
AdminName = Me.Admin_Name
DoCmd.OpenForm "Cleansed Clients", acNormal, , "[AdminName] = [Forms]![Cleansed Clients]![Admin Name]" End Sub

Sponsored Links:

Related Topics

DoCmd.OutputTo AcFormatPDF
I'm trying to use DoCmd.OutputTo to save a report as a PDF file. The trouble I'm having is that it seems to ignore the formatting set in VBA. In this case if a certain condition is true thePageHeader is hidden, the problem is that DoCmd.OutputTo prints that header even if the condition is true.

Is there a way around it? Am I missing something?

Using where condition of DoCmd.BrowseTo with navigation form (Access 2010)
I now can successfully get Access to open the navigation formto the correct tab using DoCmd.BrowseTo.

DoCmd.BrowseTo acBrowseToForm, "frmGuestInfo", "Main.NavigationSubform", "[GuestID] = " & lngGuestID

The secret was that I had to close the search form that was in use, so that the already open navigation form, "Main", would be visible, or the active form.

However, I cannot get the where condition to work at all. It has been some years since I worked with Access, so I'm sure I'm probably missing something simple, but I have tried many variations of ways to specify the where condition.

I was able to specify a filter on the form in question, frmGuestInfo, that worked as expected, but the same filter did not work when specified as the where condition of the DoCmd.BrowseTo command. lngGuestID does evaluate in code properly, so that is not the problem.

Open Report or Form depending on condition
I have a form that needs to either open a report if one condition is met or open a form if that same condition is not met. i can do one as well as the other but I can't get them to work together. There seems to be an issue using Openform and Openreport together. Any help is appreciate. This is what I have so far:

Private Sub RCRA_Continue_Click()
If Me.[dot_transport?] = "-1" Then
DoCmd.OpenForm "frm_DOT"
DoCmd.OpenReport "output"
End If
End Sub

The condition is DOT_Transport? and the Form is frm_DOT while the report is Output.

VBA Loop through, check condition, replace
I want to write a vba code to loop through a column in my table and check for a condition, and where it does not equal that condition I want it to display the whole row in a message box and ask to amend the field to meet that condition. If I say Yes I want the amendment to proceed.

For example, the fields would be mostly say 31/08/2012 but one entry may be 30/07/2012. I want the code to pick this out and suggest whether I want to change this to 31/08/2012.

Difference between using Query based Report and Where Condition in OpenReport
I was just wondering what the difference between using a report based on a query, where one field in the query has a parameter as a criteria, and the where condition in docmd.openreport is?

For example, I wanted to create a receipt type report that would would open based on a transaction number. So I created a query that prompts for transaction number and then based a report on that query.

Now I am trying to get a button to perform some code (which I have already tested and is working) and open the report based on the transactions number. I would have thought I would need VBA to fill in the transaction number, but I can't get that syntax correct, and adding a where condition doesn't seem to work either.

Here is a sample of my syntax:

MsgBox "Would you like to print a receipt?", vbYesNo,
If vbYes Then DoCmd.OpenReport "Check_Out_Receipt_rpt", acViewPreview, , NextTransactionNum
ElseIf vbNo Then
MsgBox "Receipt will not be printed"
End If

Where NextTransactionNum is a number that is populated via prior code my taking the max of the numbers in a particular field in a table and adding 1.

OpenReport function
I wrote this function in a click event of a boutton

DoCmd.OpenReport "customer_account", acViewPreview, , "[nam]='" & Me.Combo4 & "'"

can I add another condition beside the one in the function. In other words, the last partion of the OpenReport function (condition) could be more than one.

Print Question
I have a macro that generates a report based on a query with a date range condition and a field value condition of -1. When the macro runs and both conditions are met I get what I want. However when the -1 condition fails, or is 0, I still get the report with #error which is to be expected.

I have tried using the where conditon field in the macro and set it so the field value is equal to -1 but I still get the report with the #Error.

Is there a way to not have the report print when the second condition is not -1?

Iif condition in a macro
Was hoping to get some help setting up an Iif condition.
I have a RunApp Action set up and would like to place an Iif condition next to it basically stating if today's date is a Saturday, quit application.

What I have tried is this and it does not work: Iif(Date(), "dddd")="Saturday"
I have the Quit Action below the RunApp Action, so if the condition is met it will quit the app, if condition is not met run the app

How can I hide/unhide DB window with a single button?
I'm trying to hide/unhide database window, I've got some idea from the web.
Private Sub cmdHide_Click()
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand acCmdWindowHide
End Sub
Private Sub cmdShow_Click()
DoCmd.SelectObject acTable, , True
End Sub

It works but it needs two buttons, one for hide and one for unhide.

I guess there must be some way to combine them into one button with if statement or something like that.

But how do I know if DB window has been hidden or not? So that I can put it into if statement as condition? Or are there any other ways to do that

Access 2003 Macro Condition
I have an Access macro in which I would like to test for the existence of a temporary table before execution of a DeleteObject action that deletes that table.

This macro has been running for years but every once in a while the table does not exist (reasons unknown at this time) and the macro terminates abnormally.

What condition do I put in the condition column to accomplish this?

DoCmd OpenReport ... where condition with a Like
DoCmd.OpenReport "R_Client_Job", acViewReport, , "Job_Name Like *" & Txt_KeyWord & "*"

this is my code and I always get error 3075 missing operator or something and it's bothering me. I did this with a macro but now I need to do it with vb since the macro can't do as much some code can

Issue with conditional imput
I'm trying to set a condition in a field on a form.

I have 2 fields:
STATUS sets the status of a case > CLOSED or OPENED

I would like to know how to do that the cell in the STATUS CONDITION becomes (BLANK) when the choice on STATUS is CLOSED.
Because in a CLOSED case there is no more need of raison

LIKE Condition (using wildcards) in Access 2007
The LIKE condition allows you to use wildcards in the where clause of an SQL statement in in Access 2007. This allows you to perform pattern matching. The LIKE condition can be used in any valid SQL statement - select, insert, update, or delete.

Macro If Condition.
I want to run a Query-B based on condition of another Query-A in Macros or VBA Code.

Query-A | Select name from employee where inserted_date= date() //today's date

Query-B -- bla bla

My Need is if Query-A returns any values, Query B need to be executed. I Tried with IF CONDITION in macros but its saying table name not found.

Autokey macro will not print reports using a condition
I'm working with Access 2003 and using an AutoKey macro with F10 to print some reports base on a condtion in a field. It will not recognize the condition for some reason. Now I copy the app to another computer and it works fine. When I remove the condition on the original computer, the reports prints normal. This is puzzling me

if is conditional formating true then...
necessary, consult the following scripts
in cells is by using conditional formatting nastevena condition:

1 if the value is greater than 10 red cell will be
2, where the lower green

Need data to other cells when the code will write a condition in a cell "OK" if the condition of two write "NOK"
I tried using ForeColor, but somehow it did not work

Query criteria in linked table
I'm relatively new to the Access game but amd trying to extract some data from a healthcare database that I have created.

There is the main table with standard/simple data which has a linked table that allows multiple values to be entered. I have created queries that will count how often each individual response has been entered however I want to create a query that tells me how many records have more than one (multi)value selected.

This would mean that in our reporting we could say x% of people have this condition, x% of people have this condition, x% of people have this condition while x% of all respondents had more than one condition.

NB. The linked multivalue table has approx 20possible responses while the main table has about 1000 records

Setting a condition in a Macro (lookin at a check box in a form)
I am trying to set a condition in a macro based on whether a check box is a form is checked or not. This is my condition:


I've also tried:


Currently, I am just having it display a MsgBox if the condition is met. However, the MsgBox is displayed regardless of whether the check box is checked or not in the form

Where Condition - form error
This database is set up so that before any forms are opened on the main page, a Family must be searched/selected first. I had used the Where Condition ="[FuID]=" & [FuID] so that when the form opens, records for that particular family are filtered. This works great. but if there is no family selected and you try to open one of the forms, an error message appears. " Syntax error (missing operator) in query expression '[FuID]='. How do I still use the above where condition, but also ask, if there is no FuID selected, open the form blank? I am not familiar with code and was fortunate to have someone help with the Where Condition I am currently using

Can't figure out how to end a procedure on meet condition fail
I have a form with a checkbox and a comand button. When I have the following:

Private Sub cmdContinue_Click()
If Me.chkCertify = False Then MsgBox "You must check the cetification box indicating you have read the warning and certifty the accuracy of the entered information."
DoCmd.OpenForm "frmTrainingMultInput"
DoCmd.Close acForm, "frmSchoolNomMultiple"
DoCmd.Close acForm, "frmTrainingMultInputCertify"
End Sub

This is the first VBA code I have ever written entirely on my own. If the user clicks the button without the check box selected, the message displays, but when they click 'Ok', it continues the code and opens/closes the forms without the check box ever being selected.

I am not sure what to put where to get the code to stop and go back to frmTrainingMultInputCertify