printing reports

G

Guest

i have been trying to add a button so i can print a report based on the
current record in my form.... what i have so far is
Me.refresh
DoCmd.OpenReport "contract", acViewPreview, , "customer_id =" & Me!customer_ID

contract is the name of the report i want to open and customer id is the
prime key
I dont know what is wrong with the way i have this writen but when i try to
"use" it it goes to the debug... Anyone know what i did wrong and how to fix
it Thanks
 
F

fredg

i have been trying to add a button so i can print a report based on the
current record in my form.... what i have so far is
Me.refresh
DoCmd.OpenReport "contract", acViewPreview, , "customer_id =" & Me!customer_ID

contract is the name of the report i want to open and customer id is the
prime key
I dont know what is wrong with the way i have this writen but when i try to
"use" it it goes to the debug... Anyone know what i did wrong and how to fix
it Thanks

Most likely [Customer_ID] is a Text datatype field, not Number.

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"
 
G

Guest

customer_id is an auto number prime key from my only table, I tryed copying
the code you sent but it still asks me to debug it, I still have no idea
what could be wrong. . . help!

fredg said:
i have been trying to add a button so i can print a report based on the
current record in my form.... what i have so far is
Me.refresh
DoCmd.OpenReport "contract", acViewPreview, , "customer_id =" & Me!customer_ID

contract is the name of the report i want to open and customer id is the
prime key
I dont know what is wrong with the way i have this writen but when i try to
"use" it it goes to the debug... Anyone know what i did wrong and how to fix
it Thanks

Most likely [Customer_ID] is a Text datatype field, not Number.

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"
 
F

fredg

customer_id is an auto number prime key from my only table, I tryed copying
the code you sent but it still asks me to debug it, I still have no idea
what could be wrong. . . help!

fredg said:
i have been trying to add a button so i can print a report based on the
current record in my form.... what i have so far is
Me.refresh
DoCmd.OpenReport "contract", acViewPreview, , "customer_id =" & Me!customer_ID

contract is the name of the report i want to open and customer id is the
prime key
I dont know what is wrong with the way i have this writen but when i try to
"use" it it goes to the debug... Anyone know what i did wrong and how to fix
it Thanks

Most likely [Customer_ID] is a Text datatype field, not Number.

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"

I see your code says "Customer_id" but one line down you write
"and customer id is the prime key".
Customer Id is not the same as Customer_Id.
Are you sure you spelled the field name correctly?

If you hover the cursor over Me![customer_Id] (while in Debug) do you
get the correct customer_Id number value?

Are you sure you spelled the report name correctly?

What error number and error message do you get?
 
G

Guest

hay fredg, I see how i would have made it confusing to understand... i
thought that when you do anything in code you have to repersent any spaces
with the _ anyway the code i have right now is:
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"
and the error message i get is
run-time error "424"
object required.
i did try to take the _ out of the customer_id and the error i get is the same
thanks for all your help on this... its been driving me crazy lol

fredg said:
customer_id is an auto number prime key from my only table, I tryed copying
the code you sent but it still asks me to debug it, I still have no idea
what could be wrong. . . help!

fredg said:
On Sat, 22 Sep 2007 10:44:02 -0700, datahunter wrote:

i have been trying to add a button so i can print a report based on the
current record in my form.... what i have so far is
Me.refresh
DoCmd.OpenReport "contract", acViewPreview, , "customer_id =" & Me!customer_ID

contract is the name of the report i want to open and customer id is the
prime key
I dont know what is wrong with the way i have this writen but when i try to
"use" it it goes to the debug... Anyone know what i did wrong and how to fix
it Thanks

Most likely [Customer_ID] is a Text datatype field, not Number.

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"

I see your code says "Customer_id" but one line down you write
"and customer id is the prime key".
Customer Id is not the same as Customer_Id.
Are you sure you spelled the field name correctly?

If you hover the cursor over Me![customer_Id] (while in Debug) do you
get the correct customer_Id number value?

Are you sure you spelled the report name correctly?

What error number and error message do you get?
 
U

UpRider

DH, put
Msgbox "Customer_ID = " & Customer_ID
just before the docmd.openreport...
and see if it displays a valid number or throws an error.
If it throws an error, there is no Customer_ID control on your form or its
datasource.
Also take out the single quotes if Customer_ID is an autonumber.

UpRider

datahunter said:
hay fredg, I see how i would have made it confusing to understand... i
thought that when you do anything in code you have to repersent any spaces
with the _ anyway the code i have right now is:
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"
and the error message i get is
run-time error "424"
object required.
i did try to take the _ out of the customer_id and the error i get is the
same
thanks for all your help on this... its been driving me crazy lol

fredg said:
customer_id is an auto number prime key from my only table, I tryed
copying
the code you sent but it still asks me to debug it, I still have no
idea
what could be wrong. . . help!

:

On Sat, 22 Sep 2007 10:44:02 -0700, datahunter wrote:

i have been trying to add a button so i can print a report based on
the
current record in my form.... what i have so far is
Me.refresh
DoCmd.OpenReport "contract", acViewPreview, , "customer_id =" &
Me!customer_ID

contract is the name of the report i want to open and customer id is
the
prime key
I dont know what is wrong with the way i have this writen but when i
try to
"use" it it goes to the debug... Anyone know what i did wrong and how
to fix
it Thanks

Most likely [Customer_ID] is a Text datatype field, not Number.

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"

I see your code says "Customer_id" but one line down you write
"and customer id is the prime key".
Customer Id is not the same as Customer_Id.
Are you sure you spelled the field name correctly?

If you hover the cursor over Me![customer_Id] (while in Debug) do you
get the correct customer_Id number value?

Are you sure you spelled the report name correctly?

What error number and error message do you get?
 
G

Guest

UpRider thanks for the help but here is what happened the extra line you
asked me to put in works just fine a popup box came up with customer_id = #
and it was the right number tryed it several times.... lol but you also
said to remove the single quotes if customer_id was an auto number.... well
it is but im not which quotes you mean my curent code now is:
Me.refresh
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Customer_ID = " & customer_ID
DoCmd.OpenReport "contract", acViewPreview, , "[customer id] ='" &
maintable![customer ID] = "'"
what should i do now? as is i still get the same error code as before.
thanks all !!

UpRider said:
DH, put
Msgbox "Customer_ID = " & Customer_ID
just before the docmd.openreport...
and see if it displays a valid number or throws an error.
If it throws an error, there is no Customer_ID control on your form or its
datasource.
Also take out the single quotes if Customer_ID is an autonumber.

UpRider

datahunter said:
hay fredg, I see how i would have made it confusing to understand... i
thought that when you do anything in code you have to repersent any spaces
with the _ anyway the code i have right now is:
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"
and the error message i get is
run-time error "424"
object required.
i did try to take the _ out of the customer_id and the error i get is the
same
thanks for all your help on this... its been driving me crazy lol

fredg said:
On Sat, 22 Sep 2007 15:08:00 -0700, datahunter wrote:

customer_id is an auto number prime key from my only table, I tryed
copying
the code you sent but it still asks me to debug it, I still have no
idea
what could be wrong. . . help!

:

On Sat, 22 Sep 2007 10:44:02 -0700, datahunter wrote:

i have been trying to add a button so i can print a report based on
the
current record in my form.... what i have so far is
Me.refresh
DoCmd.OpenReport "contract", acViewPreview, , "customer_id =" &
Me!customer_ID

contract is the name of the report i want to open and customer id is
the
prime key
I dont know what is wrong with the way i have this writen but when i
try to
"use" it it goes to the debug... Anyone know what i did wrong and how
to fix
it Thanks

Most likely [Customer_ID] is a Text datatype field, not Number.

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


I see your code says "Customer_id" but one line down you write
"and customer id is the prime key".
Customer Id is not the same as Customer_Id.
Are you sure you spelled the field name correctly?

If you hover the cursor over Me![customer_Id] (while in Debug) do you
get the correct customer_Id number value?

Are you sure you spelled the report name correctly?

What error number and error message do you get?
 
F

fredg

UpRider thanks for the help but here is what happened the extra line you
asked me to put in works just fine a popup box came up with customer_id = #
and it was the right number tryed it several times.... lol but you also
said to remove the single quotes if customer_id was an auto number.... well
it is but im not which quotes you mean my curent code now is:
Me.refresh
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Customer_ID = " & customer_ID
DoCmd.OpenReport "contract", acViewPreview, , "[customer id] ='" &
maintable![customer ID] = "'"
what should i do now? as is i still get the same error code as before.
thanks all !!

UpRider said:
DH, put
Msgbox "Customer_ID = " & Customer_ID
just before the docmd.openreport...
and see if it displays a valid number or throws an error.
If it throws an error, there is no Customer_ID control on your form or its
datasource.
Also take out the single quotes if Customer_ID is an autonumber.

UpRider

datahunter said:
hay fredg, I see how i would have made it confusing to understand... i
thought that when you do anything in code you have to repersent any spaces
with the _ anyway the code i have right now is:
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"
and the error message i get is
run-time error "424"
object required.
i did try to take the _ out of the customer_id and the error i get is the
same
thanks for all your help on this... its been driving me crazy lol

:

On Sat, 22 Sep 2007 15:08:00 -0700, datahunter wrote:

customer_id is an auto number prime key from my only table, I tryed
copying
the code you sent but it still asks me to debug it, I still have no
idea
what could be wrong. . . help!

:

On Sat, 22 Sep 2007 10:44:02 -0700, datahunter wrote:

i have been trying to add a button so i can print a report based on
the
current record in my form.... what i have so far is
Me.refresh
DoCmd.OpenReport "contract", acViewPreview, , "customer_id =" &
Me!customer_ID

contract is the name of the report i want to open and customer id is
the
prime key
I dont know what is wrong with the way i have this writen but when i
try to
"use" it it goes to the debug... Anyone know what i did wrong and how
to fix
it Thanks

Most likely [Customer_ID] is a Text datatype field, not Number.

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


I see your code says "Customer_id" but one line down you write
"and customer id is the prime key".
Customer Id is not the same as Customer_Id.
Are you sure you spelled the field name correctly?

If you hover the cursor over Me![customer_Id] (while in Debug) do you
get the correct customer_Id number value?

Are you sure you spelled the report name correctly?

What error number and error message do you get?

Regarding your syntax
DoCmd.OpenReport "contract", acViewPreview, , "[customer id] ='" &
maintable![customer ID] = "'"

You're adding extra stuff that isn't correct.

If, as you state, [Customer_Id] is an Autonumber field, then use:
DoCmd.OpenReport "contract", acViewPreview, , "[customer id] =" &
Me![customer ID]
 
G

Guest

well i changed the code and removed the "extra" stuff now i get
run-time error '3075'
malformed GUID. in query expression '({customer id]=3)'.
=3 is the record i chose for the test


fredg said:
UpRider thanks for the help but here is what happened the extra line you
asked me to put in works just fine a popup box came up with customer_id = #
and it was the right number tryed it several times.... lol but you also
said to remove the single quotes if customer_id was an auto number.... well
it is but im not which quotes you mean my curent code now is:
Me.refresh
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Customer_ID = " & customer_ID
DoCmd.OpenReport "contract", acViewPreview, , "[customer id] ='" &
maintable![customer ID] = "'"
what should i do now? as is i still get the same error code as before.
thanks all !!

UpRider said:
DH, put
Msgbox "Customer_ID = " & Customer_ID
just before the docmd.openreport...
and see if it displays a valid number or throws an error.
If it throws an error, there is no Customer_ID control on your form or its
datasource.
Also take out the single quotes if Customer_ID is an autonumber.

UpRider

hay fredg, I see how i would have made it confusing to understand... i
thought that when you do anything in code you have to repersent any spaces
with the _ anyway the code i have right now is:
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"
and the error message i get is
run-time error "424"
object required.
i did try to take the _ out of the customer_id and the error i get is the
same
thanks for all your help on this... its been driving me crazy lol

:

On Sat, 22 Sep 2007 15:08:00 -0700, datahunter wrote:

customer_id is an auto number prime key from my only table, I tryed
copying
the code you sent but it still asks me to debug it, I still have no
idea
what could be wrong. . . help!

:

On Sat, 22 Sep 2007 10:44:02 -0700, datahunter wrote:

i have been trying to add a button so i can print a report based on
the
current record in my form.... what i have so far is
Me.refresh
DoCmd.OpenReport "contract", acViewPreview, , "customer_id =" &
Me!customer_ID

contract is the name of the report i want to open and customer id is
the
prime key
I dont know what is wrong with the way i have this writen but when i
try to
"use" it it goes to the debug... Anyone know what i did wrong and how
to fix
it Thanks

Most likely [Customer_ID] is a Text datatype field, not Number.

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


I see your code says "Customer_id" but one line down you write
"and customer id is the prime key".
Customer Id is not the same as Customer_Id.
Are you sure you spelled the field name correctly?

If you hover the cursor over Me![customer_Id] (while in Debug) do you
get the correct customer_Id number value?

Are you sure you spelled the report name correctly?

What error number and error message do you get?

Regarding your syntax
DoCmd.OpenReport "contract", acViewPreview, , "[customer id] ='" &
maintable![customer ID] = "'"

You're adding extra stuff that isn't correct.

If, as you state, [Customer_Id] is an Autonumber field, then use:
DoCmd.OpenReport "contract", acViewPreview, , "[customer id] =" &
Me![customer ID]
 
U

UpRider

DH, you must have consistency!
Access will not replace your spaces with an underline _, you have to do that
yourself.
*ANY* controlname that contains a space MUST be enclosed in brackets, and it
doesn't hurt to use brackets anyway.
Is it
[customer id]
customerid or
customer_id
?
If the msgbox code I gave your before displaying Customer_ID worked, then
you must use Customer_ID in your criteria.
Also to simplify things, make sure the *TABLE* fieldname is the same as the
*FORM* controlname.
The docmd syntax, after you straighten out the name of customer_id should
be:

DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] = " &
Me.[customer_ID]

This assumes that the code is in a form's module with the form having a
bound controlname of Customer_ID

UpRider

datahunter said:
UpRider thanks for the help but here is what happened the extra line you
asked me to put in works just fine a popup box came up with customer_id =
#
and it was the right number tryed it several times.... lol but you also
said to remove the single quotes if customer_id was an auto number....
well
it is but im not which quotes you mean my curent code now is:
Me.refresh
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Customer_ID = " & customer_ID
DoCmd.OpenReport "contract", acViewPreview, , "[customer id] ='" &
maintable![customer ID] = "'"
what should i do now? as is i still get the same error code as before.
thanks all !!

UpRider said:
DH, put
Msgbox "Customer_ID = " & Customer_ID
just before the docmd.openreport...
and see if it displays a valid number or throws an error.
If it throws an error, there is no Customer_ID control on your form or
its
datasource.
Also take out the single quotes if Customer_ID is an autonumber.

UpRider

datahunter said:
hay fredg, I see how i would have made it confusing to understand... i
thought that when you do anything in code you have to repersent any
spaces
with the _ anyway the code i have right now is:
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"
and the error message i get is
run-time error "424"
object required.
i did try to take the _ out of the customer_id and the error i get is
the
same
thanks for all your help on this... its been driving me crazy lol

:

On Sat, 22 Sep 2007 15:08:00 -0700, datahunter wrote:

customer_id is an auto number prime key from my only table, I tryed
copying
the code you sent but it still asks me to debug it, I still have no
idea
what could be wrong. . . help!

:

On Sat, 22 Sep 2007 10:44:02 -0700, datahunter wrote:

i have been trying to add a button so i can print a report based
on
the
current record in my form.... what i have so far is
Me.refresh
DoCmd.OpenReport "contract", acViewPreview, , "customer_id =" &
Me!customer_ID

contract is the name of the report i want to open and customer id
is
the
prime key
I dont know what is wrong with the way i have this writen but when
i
try to
"use" it it goes to the debug... Anyone know what i did wrong and
how
to fix
it Thanks

Most likely [Customer_ID] is a Text datatype field, not Number.

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


I see your code says "Customer_id" but one line down you write
"and customer id is the prime key".
Customer Id is not the same as Customer_Id.
Are you sure you spelled the field name correctly?

If you hover the cursor over Me![customer_Id] (while in Debug) do you
get the correct customer_Id number value?

Are you sure you spelled the report name correctly?

What error number and error message do you get?
 
G

Guest

hay thanks for the help everyone! that fixed it!!
UpRider said:
DH, you must have consistency!
Access will not replace your spaces with an underline _, you have to do that
yourself.
*ANY* controlname that contains a space MUST be enclosed in brackets, and it
doesn't hurt to use brackets anyway.
Is it
[customer id]
customerid or
customer_id
?
If the msgbox code I gave your before displaying Customer_ID worked, then
you must use Customer_ID in your criteria.
Also to simplify things, make sure the *TABLE* fieldname is the same as the
*FORM* controlname.
The docmd syntax, after you straighten out the name of customer_id should
be:

DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] = " &
Me.[customer_ID]

This assumes that the code is in a form's module with the form having a
bound controlname of Customer_ID

UpRider

datahunter said:
UpRider thanks for the help but here is what happened the extra line you
asked me to put in works just fine a popup box came up with customer_id =
#
and it was the right number tryed it several times.... lol but you also
said to remove the single quotes if customer_id was an auto number....
well
it is but im not which quotes you mean my curent code now is:
Me.refresh
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Customer_ID = " & customer_ID
DoCmd.OpenReport "contract", acViewPreview, , "[customer id] ='" &
maintable![customer ID] = "'"
what should i do now? as is i still get the same error code as before.
thanks all !!

UpRider said:
DH, put
Msgbox "Customer_ID = " & Customer_ID
just before the docmd.openreport...
and see if it displays a valid number or throws an error.
If it throws an error, there is no Customer_ID control on your form or
its
datasource.
Also take out the single quotes if Customer_ID is an autonumber.

UpRider

hay fredg, I see how i would have made it confusing to understand... i
thought that when you do anything in code you have to repersent any
spaces
with the _ anyway the code i have right now is:
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"
and the error message i get is
run-time error "424"
object required.
i did try to take the _ out of the customer_id and the error i get is
the
same
thanks for all your help on this... its been driving me crazy lol

:

On Sat, 22 Sep 2007 15:08:00 -0700, datahunter wrote:

customer_id is an auto number prime key from my only table, I tryed
copying
the code you sent but it still asks me to debug it, I still have no
idea
what could be wrong. . . help!

:

On Sat, 22 Sep 2007 10:44:02 -0700, datahunter wrote:

i have been trying to add a button so i can print a report based
on
the
current record in my form.... what i have so far is
Me.refresh
DoCmd.OpenReport "contract", acViewPreview, , "customer_id =" &
Me!customer_ID

contract is the name of the report i want to open and customer id
is
the
prime key
I dont know what is wrong with the way i have this writen but when
i
try to
"use" it it goes to the debug... Anyone know what i did wrong and
how
to fix
it Thanks

Most likely [Customer_ID] is a Text datatype field, not Number.

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


I see your code says "Customer_id" but one line down you write
"and customer id is the prime key".
Customer Id is not the same as Customer_Id.
Are you sure you spelled the field name correctly?

If you hover the cursor over Me![customer_Id] (while in Debug) do you
get the correct customer_Id number value?

Are you sure you spelled the report name correctly?

What error number and error message do you get?
 
G

Guest

ok i thought it was fixed but now... i closed down the application and
restarted it and now a opup box comes up asking for the cuntomer ID but when
the report comes up it is the first record no matter what i enter as the
customer id.
maybe i need to say it this way i am trying to print a report with the data
from a specific record one at at time..... befor i tryed to put in this
command button to open the report straight from the form i could only print
all records in my report, so insted of getting the record specific "page" i
want i get all the "pages" printed.... does this help... mybe i am going
about this all wrong. thanks all

datahunter said:
hay thanks for the help everyone! that fixed it!!
UpRider said:
DH, you must have consistency!
Access will not replace your spaces with an underline _, you have to do that
yourself.
*ANY* controlname that contains a space MUST be enclosed in brackets, and it
doesn't hurt to use brackets anyway.
Is it
[customer id]
customerid or
customer_id
?
If the msgbox code I gave your before displaying Customer_ID worked, then
you must use Customer_ID in your criteria.
Also to simplify things, make sure the *TABLE* fieldname is the same as the
*FORM* controlname.
The docmd syntax, after you straighten out the name of customer_id should
be:

DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] = " &
Me.[customer_ID]

This assumes that the code is in a form's module with the form having a
bound controlname of Customer_ID

UpRider

datahunter said:
UpRider thanks for the help but here is what happened the extra line you
asked me to put in works just fine a popup box came up with customer_id =
#
and it was the right number tryed it several times.... lol but you also
said to remove the single quotes if customer_id was an auto number....
well
it is but im not which quotes you mean my curent code now is:
Me.refresh
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Customer_ID = " & customer_ID
DoCmd.OpenReport "contract", acViewPreview, , "[customer id] ='" &
maintable![customer ID] = "'"
what should i do now? as is i still get the same error code as before.
thanks all !!

:

DH, put
Msgbox "Customer_ID = " & Customer_ID
just before the docmd.openreport...
and see if it displays a valid number or throws an error.
If it throws an error, there is no Customer_ID control on your form or
its
datasource.
Also take out the single quotes if Customer_ID is an autonumber.

UpRider

hay fredg, I see how i would have made it confusing to understand... i
thought that when you do anything in code you have to repersent any
spaces
with the _ anyway the code i have right now is:
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"
and the error message i get is
run-time error "424"
object required.
i did try to take the _ out of the customer_id and the error i get is
the
same
thanks for all your help on this... its been driving me crazy lol

:

On Sat, 22 Sep 2007 15:08:00 -0700, datahunter wrote:

customer_id is an auto number prime key from my only table, I tryed
copying
the code you sent but it still asks me to debug it, I still have no
idea
what could be wrong. . . help!

:

On Sat, 22 Sep 2007 10:44:02 -0700, datahunter wrote:

i have been trying to add a button so i can print a report based
on
the
current record in my form.... what i have so far is
Me.refresh
DoCmd.OpenReport "contract", acViewPreview, , "customer_id =" &
Me!customer_ID

contract is the name of the report i want to open and customer id
is
the
prime key
I dont know what is wrong with the way i have this writen but when
i
try to
"use" it it goes to the debug... Anyone know what i did wrong and
how
to fix
it Thanks

Most likely [Customer_ID] is a Text datatype field, not Number.

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_id] ='" &
Me![customer_ID] & "'"

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


I see your code says "Customer_id" but one line down you write
"and customer id is the prime key".
Customer Id is not the same as Customer_Id.
Are you sure you spelled the field name correctly?

If you hover the cursor over Me![customer_Id] (while in Debug) do you
get the correct customer_Id number value?

Are you sure you spelled the report name correctly?

What error number and error message do you get?
 
A

Albert D. Kallal

Check the query and field list in the reports *design* mode...

does the field customer_id exist in the query? (is has to be a legal field
in the reports data source).

Do a view->field list in reprot desing mode. Is that field in the list?
 
G

Guest

i checked my query and yes the field does exist.... right now my command
button after click i gt a popup box asking for the value of customer_ID
instead of getting from my current form where button is located. code is as
follows:
Me.refresh
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_ID]=" &
Me.[customer_ID]
so what do you think... when i enter the "value" manualy i get no data
at all in my report now
 
A

Albert D. Kallal

datahunter said:
i checked my query and yes the field does exist.... right now my command
button after click i gt a popup box asking for the value of customer_ID
instead of getting from my current form where button is located. code is
as
follows:
Me.refresh
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_ID]=" &
Me.[customer_ID]

While in the code editor, do a debug->compile...make sure your code
compiles....

further, while in the forms design mode...do a view-> field list...do you
see customer_id in the field list?

You can, and should also try the folwling syntax:


DoCmd.OpenReport
"contract", acViewPreview, , "[customer_ID]=" & Me![customer_ID]

use the ! in place of dot..

as others pointed out, try:

msgbox "id is currently = " & me![customer_id]
DoCmd.OpenReport
"contract", acViewPreview, , "[customer_ID]=" & Me![customer_ID]

Does the customer is show with the above msgbox? you *must* get that
msgbox code t work.
(when it finally works..you can remove it for production version).

If the msgbox code works fine, then need to look at this part:

"contract", acViewPreview, , "[customer_ID]=" & Me![customer_ID]


"[customer_ID] = "

Customer_id is the name of the field in the REPORT..not our form that we
using to restrict the reports output....

So, double check if the report has this field.

Further, make sure the report is closed before you run the above code....

So, from this line of code (it would be all on one line of code):

DoCmd.OpenReport
"contract", acViewPreview, , "[customer_ID]=" & Me![customer_ID]

"[customer_id] = " is the field name in the target reprot, and

me![customer_id] is the name of the field in our current form....

It not clear which of the above is causing the "prompt" to occur -- you
should not be seeing a prompt..

Also DO CHECK can you run the report on its own -- no prompts should occur,
and all records should show.. You MUST check this!!

So, if the msgbox code works, then it is the target report that does NOT
have
[customer_id] in the field list....

So, put in the msgbox code....it should show you the current customer id.

The above code assumes customer_id is a autonumber field...correct??

So, check all of the above things...and, you code MUST compile before you
attempt to run it...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top