Linking text boxes

jer

Registered User.
Local time
Today, 09:22
Joined
Nov 21, 2011
Messages
109
I have created a report that i wish to email. I did this because I cannot send a snapshot of the current form in an email. But now i dont know how to link the textboxes in the report to those in my form such that when i look up a record in my form, I can press a button to preview the report, which should have the exact same information. Also I wish to be able to email this record then. Any help will be appreciated.
Thanks
Jer
 
Could you explain further please. Im new and I dont have alot of experience with vba
 
What part of it are struggling with? And what have you tried?

If you are new to this kind of thing I would advise that you read up on the basics and concepts of VBA before attempting this.
 
I dont follow what is meant by restriction. Which field is fieldname? is that the field in the report that i want the data to go to?
 
sorry i phrased the above wrong
 
Your report will display all records so when the button is pressed on your form, it will filter the records on the report to display what is on the form.
 
where do i place this code? there is no reference to the text box in the report where i want the information to go..
 
where do i place this code? there is no reference to the text box in the report where i want the information to go..
In the ON CLICK event (i.e. Code Builder) of the button.

I hope you didn't miss my last post.
 
I tried the code and it didnt work. It said syntax error.. any ideas?
 
So show me what you tried. And tell me what the data type of the field is.
 
The name of the report I want to open and populate is "Copy of Main Form (Search By Tool Number)". The form is called "Main Form (Search By Tool Number)".

This is the code I used: DoCmd.OpenReport "Copy of Main Form (Search By Tool Number)", , , "ID = '" & Me.Tool No# & "'"

The data im trying to send is mixed. Numbers and text. I have set a field called ID as the primary key. I think this is what is meant by the fieldname section of the sample code.
 
Code:
DoCmd.OpenReport "Copy of Main Form (Search By Tool Number)", , , "ID = '" & Me.[COLOR=Red][[/COLOR]Tool No#[COLOR=Red]][/COLOR] & "'"
The main reason why you shouldn't have spaces or special characters in field or control names.
 
As you have a space in the control name you will need to put it in square brackets,

Code:
DoCmd.OpenReport "Copy of Main Form (Search By Tool Number)", , , "ID = '" & Me.[Tool No#] & "'"


(I'm not stalking you vbaInet ... honest :D)
 
Im getting a run time error 3071. It says the expression is either typed incorrectly or is too complex to be evaluated! Any ideas?
 
Are you sure that control has a value?

Just before that line of code, put this:
Code:
If Me.Dirty Then Me.Dirty = False
 
Code:
DoCmd.OpenReport "Copy of Main Form (Search By Tool Number)", , , "[B]ID = '" & Me.[Tool No#] & "'"[/B]

Err, Is ID really a string? If so, can you show us an example.

Or is ID an (auto)number?

Code:
DoCmd.OpenReport "Copy of Main Form (Search By Tool Number)", , , "[B]ID = " & Me.[Tool No#][/B]

This above lines of code will also print straight away rather than giving a Print Preview.

Code:
DoCmd.OpenReport "Copy of Main Form (Search By Tool Number)", acViewPreview, , "[B]ID = '" & Me.[Tool No#] & "'"[/B]
 
Last edited:
Im still getting the run time error 3071. It says the expression is typed incorrectly or its too complex to be evaluated. Any ideas because I got no clue :(
 

Users who are viewing this thread

Back
Top Bottom