473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Form Command Button Difficulty

Following is the code I am using, behind a command button, on a form to
print out only the report of that particular form.

******************** Code Start ************************
Dim strDocName As String
Dim strWhere As String
strDocName = "rptSomeReport"
strWhere = "[RunID]=" & me!RunID
DoCmd.OpenReport strDocName, acPreview, , strWhere
'******************** Code End ************************

The changes I have made to fit my record is as follows:

Dim strDocName As String
Dim strWhere As String
strDocName = "RptBinlabel"
strWhere = "[SlideLotNumber]=" & me!SlideLotNumber
DoCmd.OpenReport strDocName, acPreview, , strWhere

When I "click" the button on the form, I get the following error:

"Run time error '3464': Data type mismatch in the criteria expression"

When I run the debug, it highlights the bottom line of the code:

"DoCmd.OpenReport strDocName, acPreview, , strWhere"

I'm stuck... :) any help would be appreciated.

Bill.

Nov 12 '05 #1
8 6958
What is the data type of SlideLotNumber in its table?
If it is a Text type field, you need extra quote marks:

strWhere = "[SlideLotNumber] = """ & me!SlideLotNumber & """"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"William Bradley" <br******@magma.ca> wrote in message
news:Gc********************@magma.ca...
Following is the code I am using, behind a command button, on a form to
print out only the report of that particular form.

******************** Code Start ************************
Dim strDocName As String
Dim strWhere As String
strDocName = "rptSomeReport"
strWhere = "[RunID]=" & me!RunID
DoCmd.OpenReport strDocName, acPreview, , strWhere
'******************** Code End ************************

The changes I have made to fit my record is as follows:

Dim strDocName As String
Dim strWhere As String
strDocName = "RptBinlabel"
strWhere = "[SlideLotNumber]=" & me!SlideLotNumber
DoCmd.OpenReport strDocName, acPreview, , strWhere

When I "click" the button on the form, I get the following error:

"Run time error '3464': Data type mismatch in the criteria expression"

When I run the debug, it highlights the bottom line of the code:

"DoCmd.OpenReport strDocName, acPreview, , strWhere"

I'm stuck... :) any help would be appreciated.

Nov 12 '05 #2
"Allen Browne" <ab***************@bigpond.net.au> wrote in message
news:Kx********************@news-server.bigpond.net.au...
What is the data type of SlideLotNumber in its table?
If it is a Text type field, you need extra quote marks:

strWhere = "[SlideLotNumber] = """ & me!SlideLotNumber & """"


Thank you for this Allen, and yes, it is a text box, but when I made the
change, nothing happens. It does not print or give me an error message.

Bill.
Following is the code I am using, behind a command button, on a form to
print out only the report of that particular form.

******************** Code Start ************************
Dim strDocName As String
Dim strWhere As String
strDocName = "rptSomeReport"
strWhere = "[RunID]=" & me!RunID
DoCmd.OpenReport strDocName, acPreview, , strWhere
'******************** Code End ************************

The changes I have made to fit my record is as follows:

Dim strDocName As String
Dim strWhere As String
strDocName = "RptBinlabel"
strWhere = "[SlideLotNumber]=" & me!SlideLotNumber
DoCmd.OpenReport strDocName, acPreview, , strWhere

When I "click" the button on the form, I get the following error:

"Run time error '3464': Data type mismatch in the criteria expression"

When I run the debug, it highlights the bottom line of the code:

"DoCmd.OpenReport strDocName, acPreview, , strWhere"

I'm stuck... :) any help would be appreciated.


Nov 12 '05 #3
William,
Allen didn't ask if the [SlideLotNumber] was a text box.
He asked if the [SlideLotNumber] Datatype was text.
Open your table in Design View.
Find the SlideLotNumber field and see what it's Datatype is.
It will say either AutoNumber or Number (which are Number DataTypes),
or Text (which is Text DataType) or Memo.

If it is Number, your original Where clause should work.
If it is text, you can use Allen's strWhere clause
or
strWhere = "[SlideLotNumber]= '" & me!SlideLotNumber & "'"

The above all assume that there is a control on your form
named "SlideLotNumber" and a field in the table named
[SlideLotNumber].
--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
"William Bradley" <br******@magma.ca> wrote in message
news:Nv********************@magma.ca...
"Allen Browne" <ab***************@bigpond.net.au> wrote in message
news:Kx********************@news-server.bigpond.net.au...
What is the data type of SlideLotNumber in its table?
If it is a Text type field, you need extra quote marks:

strWhere = "[SlideLotNumber] = """ & me!SlideLotNumber & """"


Thank you for this Allen, and yes, it is a text box, but when I made the
change, nothing happens. It does not print or give me an error message.

Bill.
Following is the code I am using, behind a command button, on a form to print out only the report of that particular form.

******************** Code Start ************************
Dim strDocName As String
Dim strWhere As String
strDocName = "rptSomeReport"
strWhere = "[RunID]=" & me!RunID
DoCmd.OpenReport strDocName, acPreview, , strWhere
'******************** Code End ************************

The changes I have made to fit my record is as follows:

Dim strDocName As String
Dim strWhere As String
strDocName = "RptBinlabel"
strWhere = "[SlideLotNumber]=" & me!SlideLotNumber
DoCmd.OpenReport strDocName, acPreview, , strWhere

When I "click" the button on the form, I get the following error:

"Run time error '3464': Data type mismatch in the criteria expression"

When I run the debug, it highlights the bottom line of the code:

"DoCmd.OpenReport strDocName, acPreview, , strWhere"

I'm stuck... :) any help would be appreciated.



Nov 12 '05 #4
At the top of your code, add this line:
Stop

When you click the button, Access should stop at this line.
Now press F8, so it moves to the next line.
Continue to press F8, one line at a time, and observe what is happening.
Does the OpenReport line exectute?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"William Bradley" <br******@magma.ca> wrote in message
news:Nv********************@magma.ca...
"Allen Browne" <ab***************@bigpond.net.au> wrote in message
news:Kx********************@news-server.bigpond.net.au...
What is the data type of SlideLotNumber in its table?
If it is a Text type field, you need extra quote marks:

strWhere = "[SlideLotNumber] = """ & me!SlideLotNumber & """"


Thank you for this Allen, and yes, it is a text box, but when I made the
change, nothing happens. It does not print or give me an error message.

Bill.
Following is the code I am using, behind a command button, on a form to print out only the report of that particular form.

******************** Code Start ************************
Dim strDocName As String
Dim strWhere As String
strDocName = "rptSomeReport"
strWhere = "[RunID]=" & me!RunID
DoCmd.OpenReport strDocName, acPreview, , strWhere
'******************** Code End ************************

The changes I have made to fit my record is as follows:

Dim strDocName As String
Dim strWhere As String
strDocName = "RptBinlabel"
strWhere = "[SlideLotNumber]=" & me!SlideLotNumber
DoCmd.OpenReport strDocName, acPreview, , strWhere

When I "click" the button on the form, I get the following error:

"Run time error '3464': Data type mismatch in the criteria expression"

When I run the debug, it highlights the bottom line of the code:

"DoCmd.OpenReport strDocName, acPreview, , strWhere"

I'm stuck... :) any help would be appreciated.

Nov 12 '05 #5

"Fredg" <fg******@att.net> wrote in message
news:19***********************@bgtnsc05-news.ops.worldnet.att.net...
William,
Allen didn't ask if the [SlideLotNumber] was a text box.
He asked if the [SlideLotNumber] Datatype was text.
Open your table in Design View.
Find the SlideLotNumber field and see what it's Datatype is.
It will say either AutoNumber or Number (which are Number DataTypes),
or Text (which is Text DataType) or Memo.

If it is Number, your original Where clause should work.
If it is text, you can use Allen's strWhere clause
or
strWhere = "[SlideLotNumber]= '" & me!SlideLotNumber & "'"

The above all assume that there is a control on your form
named "SlideLotNumber" and a field in the table named
[SlideLotNumber].


Thank you Fredg, the datatype is text. Your code above does bring the
appropriate report to the screen but does not print it. Which is what I am
trying to achieve. When the operator fills out the form, I want them to be
able to hit "Print Report" and the appropriate form will then print out and
that report only. As you know to simply hit "print" in reports, gets you all
of them unless you select a particular record.

Bill.
Nov 12 '05 #6

"Allen Browne" <ab***************@bigpond.net.au> wrote in message
news:o9********************@news-server.bigpond.net.au...
At the top of your code, add this line:
Stop

When you click the button, Access should stop at this line.
Now press F8, so it moves to the next line.
Continue to press F8, one line at a time, and observe what is happening.
Does the OpenReport line exectute?


Thank you Allen and yes it does step through all the lines. It brings the
appropriate report to the screen but does not print it out. Maybe something
is missing in the code. I got this code from:
http://www.mvps.org/access/reports/rpt0002.htm

Bill.
Nov 12 '05 #7
"Jamie" <ji*************@hotmail.com> wrote in message
news:bk**********@news7.svr.pol.co.uk...
Your problem is with the DoCmd line:
DoCmd.OpenReport strDocName, acPreview, , strWhere

You are using acPreview which is supposed to preview the report on the
screen, you should instead use acViewNormal:
DoCmd.OpenReport strDocName, acViewNormal, , strWhere

This command will print your report.


Thank you for this Jamie, I will give it a try.

Bill.
Nov 12 '05 #8
Saloc
23
Im trying similar I need to print only the report page that coisides with the form I am filling in at that time.

both report and form are in Justified

they are for searchs ie we collate data per search on one form and have to print out one report page = one a4 paper size per report

ive tried using certain codes building it into the form command button I have designated in the expression build area ((right clicking on button))

I am new to this sort of thing but really want to learn it Pleae can some one explain in english for me ive used the codes above but seem to be doing some thing wrong because im getting nothing or all report pages and I have a data base of over a thousand :confused: :eek: :mad:
Jul 14 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: RBohannon | last post by:
I have a report with most fields populated by a query. However, some of the fields are variable in such a way that their values cannot be queried from a table. At present the values for these...
1
by: longtim | last post by:
I have been having endless difficulty creating reports/queries that set any relevent parameters from controls in forms. I am creating an application under access 2003 but will target access...
4
by: glenhong | last post by:
Hi I need some help here. I am running Access 2003. I have an Access DB linked (Front-end) to another Access DB (Back-end). I have a Form which has a third party grid on it. The grid is...
1
by: John Phelan-Cummings | last post by:
When I add the name of a new individual in a, bound form, it will not display that person’s name in a label control of a second unbound form. I have a scheduling program that I am working on. ...
15
by: scatterbrain | last post by:
I'm trying to create a popup form so that my peers have and easy way to filter information by 4 categories: Presenter, Evaluator, Date, or Topic. All this information is stored in my Data table and I...
2
easydoesit
by: easydoesit | last post by:
Hello all, I am looking for a way to be able to enter data into fields on a form, then be able to e-mail a report that shows only that record. This is what I have thus far: At the end of my...
0
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
1
by: mirandacascade | last post by:
1) Module1 has the following delcaration: Public g_frmZZZ as Form Public g_txtForm2 as Variant 2) app has two forms: form1 and form2 3) a command button on form1 opens form2; it also has...
4
by: zufie | last post by:
I have a main form containing a command SEND button that prompts an email form to pop up. The email address(es) that are supposed to appear on the email form are those corresponding to the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
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,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.