I created two Command buttons in a form, one to preview the entire report and one to "cancel" or exit the form. They both work. I'm trying to create a third Command button to select/filter data from the report. My code to filter the data is:
Private Sub SelectedContrac t_Click()
On Error GoTo Err_SelectedCon tract_Click
strFilter = "[LeaseMasterCont ractId] = '" & Me![LeaseMasterCont ractId] & "'"
DoCmd.OpenRepor t "OPTIMIZEIT-Audit1", acViewPreview, , strFilter
Exit_SelectedCo ntract_Click:
Exit Sub
Err_SelectedCon tract_Click:
MsgBox Err.Description
Resume Exit_SelectedCo ntract_Click
End Sub
I get the error message "Cannot find the field 'LeaseMasterCon tractId' referred to in your expression." I know the field name and report name are correct. I'm not very knowledgeable about VBA so I appreciate any help you can provide.
Krazy
3 2311 Dököll 2,364
Recognized Expert Top Contributor
I created two Command buttons in a form, one to preview the entire report and one to "cancel" or exit the form. They both work. I'm trying to create a third Command button to select/filter data from the report. My code to filter the data is: -
Private Sub SelectedContract_Click()
-
On Error GoTo Err_SelectedContract_Click
-
-
strFilter = "[LeaseMasterContractId] = '" & Me![LeaseMasterContractId] & "'"
-
DoCmd.OpenReport "OPTIMIZEIT-Audit1", acViewPreview, , strFilter
-
-
Exit_SelectedContract_Click:
-
Exit Sub
-
-
Err_SelectedContract_Click:
-
MsgBox Err.Description
-
Resume Exit_SelectedContract_Click
-
-
End Sub
-
-
I get the error message "Cannot find the field 'LeaseMasterCon tractId' referred to in your expression." I know the field name and report name are correct. I'm not very knowledgeable about VBA so I appreciate any help you can provide.
Krazy
Greetings, KrazyKasper!
Have you tried having your wizard create certain buttons for you?
Here is what I have working to exit my database: -
-
Private Sub QuitMeNow_Click()
-
On Error GoTo Err_QuitMeNow_Click
-
-
-
DoCmd.Quit
-
-
Exit_QuitMeNow_Click:
-
Exit Sub
-
-
Err_QuitMeNow_Click:
-
MsgBox Err.Description
-
Resume Exit_QuitMeNow_Click
-
-
End Sub
-
-
Nothing fancy just add code under your button named QuitMeNow
Here is what I ahve to pull up my reports, same deal created through wizard: -
-
'Opens Open Report
-
Private Sub OpenOpenReport_Click() ' this is your button
-
On Error GoTo ErrHandler
-
DoCmd.OpenReport "OpenMeReport", acPreview, acEdit
-
ErrHandler:
-
Exit Sub
-
End Sub
-
-
I actually have a bit of code with the report using the On No Data procedure pane that'll allow report to not load when empty, thus get to your report in design view and add the additional info so it works well with the code above: -
-
Option Compare Database
-
-
-
Private Sub Report_NoData(Cancel As Integer)
-
On Error GoTo ErrHandler
-
ErrHandler:
-
MsgBox "Sorry! There are no records to display for this report." & vbCrLf & vbCrLf & _
-
"Please be sure data available in the system to continue...", vbInformation + vbOKOnly, _
-
"Data Central Report Error"
-
Cancel = True
-
Exit Sub
-
End Sub
-
Hope this helps you:-)
In a bit!
Dököll
I created two Command buttons in a form, one to preview the entire report and one to "cancel" or exit the form. They both work. I'm trying to create a third Command button to select/filter data from the report. My code to filter the data is:
Private Sub SelectedContrac t_Click()
On Error GoTo Err_SelectedCon tract_Click
strFilter = "[LeaseMasterCont ractId] = '" & Me![LeaseMasterCont ractId] & "'"
DoCmd.OpenRepor t "OPTIMIZEIT-Audit1", acViewPreview, , strFilter
Exit_SelectedCo ntract_Click:
Exit Sub
Err_SelectedCon tract_Click:
MsgBox Err.Description
Resume Exit_SelectedCo ntract_Click
End Sub
I get the error message "Cannot find the field 'LeaseMasterCon tractId' referred to in your expression." I know the field name and report name are correct. I'm not very knowledgeable about VBA so I appreciate any help you can provide.
Krazy
The field name must be in the dataset behind the form and on the form itself to be "seen" in your code. Is it there? Also, perhaps an easier way to pull this off is to parameterize your report query and reference the field on your form. To open the report, you'll only need the line you have to open the report as the filter will be "built in" to the query behind the report.
Got it done.
Thanks for your help.
Krazy (Bill) Kasper
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Sam |
last post by:
Trying to change the visible property on a command button (access97) based
on a record felid on the form.
The felid is a check box felid and I am trying to make the button disappear
with the check box s checked.
The commend button name is command36 and the check bx feild is named .
I have written the following code:
IIf Me! = True, Me!Command36.Visible = -1, Me!Command36.Visible
|
by: Chris Bolus |
last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some
workstations both I and my students sometimes get an error message
when attempting to insert a command button on a form which reads
"Invalid
use of null". The remainder of the options in the Command Button
Wizard are then unavailable and
the button wil not work.
The only solution is to log on to a different workstation.
Any ideas?
|
by: randyelliott |
last post by:
Good Day,
I have a MS Access (Access 2000 now upgraded to 2003) database that
tracks customer information. One function of this database is to
create an encrypted license file for our software, which is then
emailed out to the customer. The encryption string is based on
information in the database and can only be generated by executing a
DOS command. This is done from within the database by clicking a
button on a form that triggers a...
|
by: Kevin |
last post by:
A couple of easy questions here hopefully. I've been working on two
different database projects which make use of multiple
forms.
1. Where's the best/recommended placement for command buttons for things
like delete, save, edit, cancel buttons - in the footer, or on the form
detail section?
2. If in the footer, how do you add them to the tab order?
|
by: M G Henry |
last post by:
I am using Access 2003 and have a form with two subforms on them.
I would like to be able to use a command button to add the row of data
( 5 fields ) that are completed on the subform, as well as refresh the
parent form which has a list box that shows the values from the first
field ( custname ) that have been added thus far to the table linked to
the subform.
My form has two subforms and I would like the command buttons to work...
| |
by: Dököll |
last post by:
Jumped for joy last night after learning, indeed, the command button wizard can be switched on or off. Well this occured here, with my Access 2000...an attempt to redo at work failed.
Here's the scenario, quite amusing, and I'll try to sum this up quickly:-)
At home, when the command button wizard (Access 2000) loads and give me some wonderful options/selection tips, the result, code is pre-written for the button when completed.
I...
|
by: Hothead |
last post by:
Hi,
I’m having difficulty getting a report in ms access 2003 to print (physically print to printer) once I’ve clicked a command button in a form. What’s the best way to do this?
I tried connecting to a printout macro however I’ve not installed the correct wizard. I’m 6,000 miles away from my home office so installing it is more difficult than it sounds.
Is there a simple way to do this using a simple sql statement?
Thanks in...
|
by: getro |
last post by:
Hi Everyone,
I need to open an Access 2003 form to a specific record from a custom Outlook 2003 Appointment form. The form has a command button that would pass a record id to access and open the appropriate record. I have searched through many Outlook and Access books and the web and cannot seem to find any info on this. Your help would be greatly appreciated.
Serge
|
by: Ken OHanlon |
last post by:
I wrote a short program that uses "SendObject". It works fine on my computer, it works fine on my clients computer, but when I copy/paste it up to the server to use it there also, Access issues the following message: The expression on click......The command or Action "SendObject" isn't available now. If you click on the See Details button you get:
Visual Basic for Applications (VBA) encountered a problem while attempting to access a...
|
by: beacon |
last post by:
Hi everybody,
I've searched and searched for the answers to these questions until I've turned blue in the face, so I finally decided to come here for some assistance.
Here's the info I'm working with:
MS Access 2003
Call log database using data access pages
One table called tblCRS_Data_Log
Primary key is CallNo
An assortment of other fields, including check, text, and combo boxes
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |