472,803 Members | 981 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Print Current Record

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 called Client Contacts.
I want to print the current record using the ID field in the Client
Contacts subform in a report.

I want to print to a report called MAIN CLIENT INFO using the current
record in the subform.

When I use:

Dim strDocName As String
Dim strFilter As String
strDocName = "MAIN CLIENT INFO2"
strFilter = "ID = Forms!CLIENT CONTACT! ID"
DoCmd.OpenReport MAIN CLIENT INFO, acViewNormal,, strFilter
It does not work.

Appreciate any help as I am new to this Access.

Nov 13 '05 #1
1 3054
First, you assign "MAIN CLIENT INFO2" to strDocName, but then don't use
strDocName. But you use MAIN CLIENT INFO (without quotes) in your OpenReport
command. So you should either use strDocName or put some quotes around MAIN
CLIENT INFO. (strDocName is not declared in your code snipped, but I assume
it's declared in your actual code.)

Second, regarding the subform, since your subform control has a space in the
name, you need to surround the name in brackets, so Access knows it's all
one name, as in [CLIENT CONTACT].

Third, you need to refer to the subform, itself, to access a field in that
form. Currently, you're just referring to the subform control. Thus, instead
of Forms![CLIENT CONTACT]!ID, you need to use Forms![CLIENT
CONTACT].Form!ID. (This assumes that the subform control name ("Name"
property of the subform control) is the same as the subform name ("Source
Object" property of the subform control.)

Fourth, you should get the ID value and concatenate it to the "ID=" part of
the string, as in:

strFilter = "ID = " & Forms![CLIENT CONTACT].Form! ID

Thus, your entire code (assuming you use strDocName) should look like this:

Dim strFilter As String
Dim strDocName as String

strDocName = "MAIN CLIENT INFO2"
strFilter = "ID = " & Forms![CLIENT CONTACT].Form! ID
DoCmd.OpenReport strDocName, acViewNormal,, strFilter

HTH,

Neil
"Randy" <ra****@msn.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
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 called Client Contacts.
I want to print the current record using the ID field in the Client
Contacts subform in a report.

I want to print to a report called MAIN CLIENT INFO using the current
record in the subform.

When I use:

Dim strDocName As String
Dim strFilter As String
strDocName = "MAIN CLIENT INFO2"
strFilter = "ID = Forms!CLIENT CONTACT! ID"
DoCmd.OpenReport MAIN CLIENT INFO, acViewNormal,, strFilter
It does not work.

Appreciate any help as I am new to this Access.

Nov 13 '05 #2

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

Similar topics

1
by: SAN CAZIANO | last post by:
I have to insert a button in the left of all record in a table to print the current record, simply create a table and print it in the printer. anyone have an idea or there is a printer/report...
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...
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...
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...
2
by: dmorand | last post by:
When I try to print a 'print version' of my page it looks fine in IE 7, but when I print in IE 6 the margins are all screwed up. The page itself looks the same in both browsers, it's just when I...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.