Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command buttons

Status
Not open for further replies.

bksras

Technical User
Jul 16, 2001
1
CA
My problem is in working with Access 97. I had been getting help from a newsgroup, but no one has answered my last question in a couple weeks. I'm just going to put in the posted messages from the newsgroup so you know what I have been dealing with. There are seven messages and they go in the order from the beginning until now.
---------------------
(message 1)
I'm working with a form in access 97. There are two buttons on the form that take you to another form. (A different form per button.) But when I press either button I get the following message:

The expression On Click you entered as the event property setting produced
the following error: Ambiguous name detected: Accreditations_Click.
*The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.

These buttons are set up to take you to another form, based on the information on the form that you are currently viewing. I would explain in detail about the database and various things in it, but that's how I started this message and it just became too long.

I was wondering why I was getting this message and how it can be fixed so that when I click on the button the form opens up, instead of the message.

I will greatly explain the database if you would like more information.

Thanks,
Ruth

(message 2)
It sounds like you have an error somewhere in your code. Open any code module and run the Menu Debug / Compile All Modules to see if any error is found. Fix the error and repeat Compile All Modules until no errors found.

Now you can try the CommandButtons again...

HTH
Van T. Dinh

(message 3)
Ok, I tried that, but since I know nothing on coding, I'm going to need a little more help here!! :) I ran the compile all modules. A second after I clicked on it, A message came up saying:

Compile Error:
Ambiguous name detected: Accreditations_Click

Then after I click OK, "Private Sub Accreditations_Click" is highlighted.
I'm assuming that's a problem, and I have no clue how to fix it!!

Thanks if you can help
Ruth

(message 4)
Ruth,
You may have 2 or more controls with the same name--Accreditations. Also, you might have 2 functions with that name. You'll need to search through the code and see if you have a duplication.

Lynn Trapp
Programmer/Analyst
Wells Dairy, Inc.
rltrapp@bluebunny.com

(message 5)
Well, I had though of that. There are 5 entries in the coding with Accreditations.
The first four say:

Private Sub Accreditations_Click()
On Error GoTo Err_Accreditations_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Accreditations"
DoCmd.OpenForm stDocName, , , StLinkCriteria

Exit_Accreditations_Click:
Exit Sub

Err_Accreditations_Click:
MsgBox Err.Description
Resume Exit _Accreditations_Click

End Sub


But the last one is just a bit different:

Private Sub Accreditations_Click()
On Error GoTo Err_Accreditations_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Accreditations"

stLinkCriteria = "[New Rep Code]=" & " ' " & Me![New Rep Code] & " ' "
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Accreditations_Click:
Exit Sub

Err_Accreditations_Click:
MsgBox Err.Description
Resume Exit_Accreditations_Click

End Sub

Now, I don't know what's going on here, or why the difference in the last one.
Would this have anything to do with the relationship between all the tables?
Because out of those tables, forms were created and I'm trying to work with the forms. Or is this something completely different?

Ruth

(message 6)
Ruth,

Is it possible you had a few attempts at creating this command button? It may be that both your buttons have the same name, or that you "messed up" on the one a few times & deleted it, then tried to recreate it with the same name. If that's the case, when you use the command button wizard to create a new one, it takes you through what you want to do and adds the code behind the form. But if you then delete that button, the object is deleted but the code stays there. So when you go to recreate it with the same name, it adds a SECOND lot of code with the same procedure/function name.

You can either go through all the procedures with that name & work out which one is the correct one & delete the others (I'd assume the last one is correct because the others don't set up a value in stLinkCriteria), or if you remember why you needed to delete & recreate so many times, and what you REALLY want the command button to do this time, delete the command button, go into the code and delete ALL the procedures referring to that button, and then create it again from the beginning - which will leave you with ONE procedure for the button and no messages about ambiguous names.

Sharon

(message 7)
Hi,
Thanks for your help. I had been trying to create the button a few times!! (The file is called "New Rep Tracking 97", so I guess that it was made a few years before I came to work on it!) So, I went back into the coding and removed the first four out of five. And I also removed the coding for the buttons, deleted the buttons on the form and created new one. After that I ran Compile All Modules, and everything was fine.
So, when I went back to the main form, to test the buttons, the forms came up, but they're not matching the information based on the main form.
The main form I'm working with is called Rep Info. There are two buttons: Details of Transfer & Old Dealer Info. In the Rep Info form there are 158 records. The Old dealer info form only has 27 records. Details of Transfer has 61 records.
Now, when I click on the button for the Transfer Details form, no matter what record I'm on, it opens up to information based on the first record on the Rep Info form. When I press the button for the Old Dealer info form, it opens up the form at the first record. When I press the OK button to close the Old Dealer info form, I'm put back at the first record in the Rep Info form, no matter what record I'm viewing. Would this have anything to do with the relationships between the tables? Each of these forms are created out of it's own table. The Rep Info and the Details of Transfer tables have the same primary key. The relationship is between them. But the Old Dealer Info table has a different primary key than the rep info table. And they're not connected through either primary key.
Thanks if you can help me out.

Ruth
-------------
That is the end of the messages. Sorry if they were too long, but that's everything that has been going on. The last message, number 7, is the one that I'm stuck with.
I hope that you can help me out with this problem.

Thanks
 
As you probably know Ambiguous means its calling itself.

So you are calling the macro from within the macro.
Try creating a another macro for different forms calling it. Just copy and paste it and give it a new name slightly different.

How many different places do you call this macro from?

Also did you try using the Debug's
open your code window and press the "F9" key on a none DIM line
this should put a red line there
Run it and it will stop then press F8 to move one line at a time. See if you are not calling it again.


DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top