473,387 Members | 1,579 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

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 3110
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.