473,387 Members | 1,834 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,387 software developers and data experts.

Print Current Record from Form

6
I am relatively new at this stuff, but I have managed to create two awesome databases for a law office. I am finishing up with a "print report from current record" command button. I have worked my way to this..
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport"File Request", acViewNormal,,"[ID] = "&Me![CLIENT]
ID is a number. This gets me where I want to be but I get a syntax error "operator missing" @ 'ID=client'. I have tried rearranging and other syntax. I have seen it done a couple of ways, but the above actually gets me to the current client data.

I need help. I am going crazy.
Jun 9 '09 #1
11 2810
ChipR
1,287 Expert 1GB
For debugging, try this.
Expand|Select|Wrap|Line Numbers
  1. Dim strWhere as String
  2. strWhere = "[ID] = " & Me.Client
  3. MsgBox strWhere   'or breakpoint for Debug
  4. DoCmd.OpenReport "File Request", acViewNormal, , strWhere
Jun 9 '09 #2
KCwiz
6
Didn't work, gave me message box "ID = Jan Smith" Ok? So I clicked ok and it returned the same error message "Syntax Error (missing operator) 'ID = Jan Smith'

If I try it a different way (I have tried so many) "on click" it asks for ID--Parameter Value

HELP, this is the last part of my db and I am done.

Kim
Jun 9 '09 #3
ChipR
1,287 Expert 1GB
Yes, it worked perfectly, but your logic is wrong. I thought you said that ID was a number. Clearly you want something other than [Client] from your form.
Jun 9 '09 #4
KCwiz
6
The ID is a number "long integer". Here's what I am doing. I want a command button on my form that will print a report of the current record based on a query I created for the report that contains the fields, CLIENT, ADDRESS, REP, TYPE. So after much googling I found
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "ReportName", acViewNormal,,"[ID] = & Me![ID]
When I use this one, it returns the "Enter Parameter Value".

Thank you so much for your quick responses!!!!

KC
Jun 9 '09 #5
ChipR
1,287 Expert 1GB
So your report does not have the [ID] field? Maybe you need:
Expand|Select|Wrap|Line Numbers
  1. Dim strWhere as String 
  2. strWhere = "[Client] = '" & Me.Client & "'"
  3. 'MsgBox strWhere   'or breakpoint for Debug 
  4. DoCmd.OpenReport "File Request", acViewNormal, , strWhere
Jun 9 '09 #6
ChipR
1,287 Expert 1GB
Consider any code you find as example only. You will very rarely be able to copy and use code without changing field names such as [ID] to the proper names that you have chosen. In this case, ID should be replaced with the name of the field you use as the primary key, which IDentifies the record.
Jun 9 '09 #7
KCwiz
6
Printed all records now.

Thanks for your help! What am I missing. It usually doesn't take me this long to "get it".

KC
Jun 9 '09 #8
KCwiz
6
I realize about the copying code. I use it to point me in the right direction. I do have an ID field (autonumber). That is why I left it in I changed it originally to ....."[ID] = "&Me! [CLIENT]
and that got me to where it was actually picking up the current record, but also giving me the syntax error (missing operator).

thanks.

KC
Jun 9 '09 #9
NeoPa
32,556 Expert Mod 16PB
@KCwiz
It's hard to know Kim.

Lookups (where you have a number associated with a string and you use that number to represent the string) are often a source of confusion.

Filtering on the [ID] value, generally requires a number. Often these numbers are hidden behind a ComboBox control where only the string value is visible. In such cases the number is generally used by the program, and needs to be passed into the SQL for the filter.

Does this make sense?
Jun 9 '09 #10
KCwiz
6
LET ME THANK YOU GUYS FOR YOUR HELP!!! I came in this a.m. and started playing around with it and this is what worked. I could swear I used this before.
Expand|Select|Wrap|Line Numbers
  1. Private Sub
  2. Dim strWhere As String
  3. DoCmd.OpenReport"REPORT", acViewNormal,,"[CLIENT] = ' " & Me.CLIENT & " ' "
  4.  
  5. End Sub
AGAIN, thanks for your help!!!!

KC
Jun 10 '09 #11
NeoPa
32,556 Expert Mod 16PB
Hi Kim. Welcome to Bytes!

Let me just add some clarification here, for other readers benefits.

This code is not copy/pasted in and should not be expected to work as is. The spaces around the single-quotes will mean that no real data is ever matched. The actual code used is not exactly as posted here. This is almost certainly due to copying the data inaccurately. It probably works fine in real-life.

As a last point, I should mention that the CODE tags must be used when posting. This is not optional. As a new member I'm sure you're just getting to grips with things so I'll include some helpful pointers on this.

Tags are done as matching pairs where the opening one is surrounded by [...] and the closing one by [/...]. A set of buttons is available for ease of use in the Standard Editor (Not the Basic Editor). The one for the [ CODE ] tags has a hash (#) on it. You can choose which editor to use in your profile options (Look near the bottom of the page).

Very last point, as I'm posting anyway, Line #2 is redundant.
Jun 10 '09 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Aftershock | last post by:
I have looked on the groups but can't seem to find an answer. I have a parameter query that uses a form for its input. This form then opens up a search result form based on the query. It is from...
0
by: Nick H | last post by:
Hi, I have a form containing a subform. I have placed some vb within the subform to print the current record. When I use this vb from within the main form, it prints all of the records for the...
2
by: Paul Mendez | last post by:
I have a form that consists of 150 records and is still growing. there are times when I want to print a certain record of the form, say record 12. I go to file --> print and choose the page number...
3
by: sea | last post by:
I need to be able to print the current form because the form has an embedded object of a .gif file, so report will not work -- does anyone know the way to do this? I tried some code, not sure what...
1
by: Randy | last post by:
I have tried the code to attach a button to a form and use the help information on coding, but I can't seem to get it to work. I have a main form called MAIN CLIENT INFO2 There is a subform...
3
by: simonmarkjones | last post by:
Hi i need to be able to print a report to act as a receipt for customers. If i put a button on a form to do this it wont print the current details on a newly created form (Prints Report with no...
6
by: shulls | last post by:
I am trying to print the curent record that I have selected on the curent page in a form that I have created, with a subform on that same page. If I just do a "print" it will print only the first...
1
by: hosi | last post by:
Hi, suppose I want to print third record from a subform. The problem is, that when I want to print what I see on my monitor (third record), the print preview resets the form to the first record...
2
by: Ste | last post by:
Hi, I would like to print the current showing record from the Form screen but don't know where to start. Here are what I have: I can print any records from report built from query that has...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
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
jinu1996
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...

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.