error when click on command

rsvrobin

Registered User.
Local time
Today, 15:41
Joined
Mar 15, 2003
Messages
21
Andy was kind enough to help me recently and everything was working well. I made a 'form' for orders and had a button to click on that would print out my current orders. Now, it seems when I click on any of the buttons I see an error " Ambiguous name detected: print_orders_click.

Anyone know how to fix it or what I've done wrong???

Robin.
 
Is there any chance you changed the name of the button. Or maybe the code?
 
you must have 2 event procedures named print_orders_click. in your code module
 
how can I change it? You're talking to a real newbie here. I have read 2 books on access and understand how it works, etc. it's the commands that i am having trouble with.

Thanks, Robin.
 
search for print_orders_click and rename one of the procedures. Post your db and im sure someone can fix it for you
 
in design view of your form
click on the icon with green red and yellow dots around a square

that will take you into the forms code module

see if you can find 2 procedures with the same
name,i.e print_orders_click

if you have 2 the same then thats the problem

you will need to determine which one is the redundant
one and delete it

before you leave the code module select from the
top tool bar debug

select compile and save

if you have no errors in the code then nothing will happen
if you still have errors this will highlight the error
 
Unfortunately I can't take credit for this. Andy helped me. This is what i have in the forms code under "general" "print_orders_click"

I believe it's for several things 1) go to next record, 2) print current record 3) review orders 4) review all orders....

Any help--grateful!!!!! Robin.

Option Compare Database

Private Sub print_orders_Click()
On Error GoTo Err_print_orders_Click


DoCmd.PrintOut

Exit_print_orders_Click:
Exit Sub

Err_print_orders_Click:
MsgBox Err.Description
Resume Exit_print_orders_Click

End Sub
Private Sub Add_new_order_Click()
On Error GoTo Err_Add_new_order_Click


DoCmd.GoToRecord , , acNewRec

Exit_Add_new_order_Click:
Exit Sub

Err_Add_new_order_Click:
MsgBox Err.Description
Resume Exit_Add_new_order_Click

End Sub
Private Sub Next_Order_Click()
On Error GoTo Err_Next_Order_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection

Exit_print_orders_Click:
Exit Sub

Err_print_orders_Click:
MsgBox Err.Description
Resume Exit_print_orders_Click

End Sub
Private Sub Add_a_Order_Click()
On Error GoTo Err_Add_a_Order_Click


DoCmd.GoToRecord , , acNewRec

Exit_Add_a_Order_Click:
Exit Sub

Err_Add_a_Order_Click:
MsgBox Err.Description
Resume Exit_Add_a_Order_Click

End Sub
Private Sub Next_Orders_Click()
On Error GoTo Err_Next_Order_Click


DoCmd.GoToRecord , , acNext

Exit_Next_Order_Click:
Exit Sub

Err_Next_Order_Click:
MsgBox Err.Description
Resume Exit_Next_Order_Click

End Sub
Private Sub Command43_Click()
On Error GoTo Err_Command43_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command43_Click:
Exit Sub

Err_Command43_Click:
MsgBox Err.Description
Resume Exit_Command43_Click

End Sub
Private Sub add_Click()
On Error GoTo Err_add_Click


DoCmd.GoToRecord , , acNewRec

Exit_add_Click:
Exit Sub

Err_add_Click:
MsgBox Err.Description
Resume Exit_add_Click

End Sub
Private Sub next_Click()
With Recordset
.MoveNext
If .EOF Then MsgBox "No More Records", vbInformation

End With
End Sub
Private Sub printcurrent_Click()
On Error GoTo Err_printcurrent_Click

Dim strDocName As String
Dim strLinkCriteria As String

strDocName = "Current Record"
strLinkCriteria = "[OrderID] = Forms![Medication Orders]![OrderID]"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenReport strDocName, acNormal, , strLinkCriteria




Exit_print_Click:
Exit Sub

Exit_printcurrent_Click:
Exit Sub

Err_printcurrent_Click:
MsgBox Err.Description
Resume Exit_printcurrent_Click

End Sub
Private Sub preview_Click()
On Error GoTo Err_preview_Click
Dim strDocName As String
Dim strLinkCriteria As String

strDocName = "Current Record"
strLinkCriteria = "[Order ID] = Forms![Medication Orders]![OrderID]"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenReport strDocName, acPreview, , strLinkCriteria


Exit_preview_Click:
Exit Sub

Err_preview_Click:
MsgBox Err.Description
Resume Exit_preview_Click

End Sub
Private Sub save_Click()
On Error GoTo Err_save_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_save_Click:
Exit Sub

Err_save_Click:
MsgBox Err.Description
Resume Exit_save_Click

End Sub
Private Sub Command53_Click()
On Error GoTo Err_Command53_Click

Dim stDocName As String

stDocName = "All orders by date"
DoCmd.OpenReport stDocName, acPreview

Exit_Command53_Click:
Exit Sub

Err_Command53_Click:
MsgBox Err.Description
Resume Exit_Command53_Click

End Sub
Private Sub print_orders_Click()
On Error GoTo Err_print_orders_Click

Dim stDocName As String
Dim MyForm As Form

stDocName = "Medication Orders"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False

Exit_print_orders_Click:
Exit Sub

Err_print_orders_Click:
MsgBox Err.Description
Resume Exit_print_orders_Click

End Sub
 
Hi, actually it's any of the buttons. I will try to reload again and make your recommended changes. I had tried to add something of my own to print all records. This is probably the problem. Rather frustrating i might add. Thanks, Robin.
 
Robin,
Just seen what you have done.
You have put another button on the form or you have changed some code on one of the buttons.

Here are the two buttons with the same name:
1st Button
Private Sub print_orders_Click()
On Error GoTo Err_print_orders_Click


DoCmd.PrintOut

Exit_print_orders_Click:
Exit Sub

Err_print_orders_Click:
MsgBox Err.Description
Resume Exit_print_orders_Click

End Sub

2nd Button

Private Sub print_orders_Click()
On Error GoTo Err_print_orders_Click

Dim stDocName As String
Dim MyForm As Form

stDocName = "Medication Orders"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False

Exit_print_orders_Click:
Exit Sub

Err_print_orders_Click:
MsgBox Err.Description
Resume Exit_print_orders_Click

End Sub

Andy
 
Robin,
Are you trying to print out the records by clicking on a button, if you are then tell us what you are trying to do and I will help you with it.

Andy
 
Andy, i want to put in 2 or 3 orders and print them as "current orders". After I print i want to click on a button to start orders on "new patient" that will save the one i just printed and begin a new one. When i have those orders (it may be 2, 3 or 4... medication orders) i want to print those, then start the process over again with "new patient". Does that make sense. You are right, i need to save data to do queries later, i liked that idea.

Heading home now, thanks for your help.

Robin.
 
Robin,
You can do a couple of things.

1)you could create a table for patients and then base a form on the patient table and include the medication orders form into that form and link the patient and order tables together with a one to many relationship

or a easier way is to

2) open the table in design view and add the following entry:

Name: Completed
data type: yes/no

then add a checkbox to the medication form, then include this field in the query and set the criteria to False.

When you complete and printed the orders, go back to the orders you have entered and tick the checkbox, then add you new records.

So when you click on print current records, it will only select the orders you have entered.

Any probs, give us a shout.
Andy
 
Andy, Thanks, I am making progress. I now have the check box (that works!). When I put in the orders (more than one) it a pop up box comes up asking me to enter parameter value. I want to click on the print button and have it print all currently active orders on the same page (not one on each page). Then after printing, I understand I should be able to check the box and have a "new patient" to start with and repeat the same process.

Thanks, Robin.
 
Andy, Also when I click on Preview Current Order it only gives me what is on my screen that i am ordering. Is there a way to have the preview show all the "current orders" for the current patient?

Thanks so much for your patience and help.
Robin.
 
Hi Robin,
Glad to see you are making progress.

to preview all the orders do the following:

open form in design view
click on preview button and select the onclick event in the properties.

In the VB code there is a line that starts:

strlinkcriteria........

Just delete this line and save your changes and you should be able to preview all the current orders.

Hope this helps.
Good Luck
Andy
;)
 
Andy, Thanks. I'm having some computer issues right now that hopefully will be resolved in the next couple of days. As soon as it is up and going, I will try. Robin.
 
Ok.
Let me know how you get on. Any probs give us a shout.

Andy
 

Users who are viewing this thread

Back
Top Bottom