Prob w/ Two Forms - One from a Parameter Query

tbaxter

In Over My Head!
Local time
Today, 10:59
Joined
Jul 19, 2000
Messages
69
I used the form wizard to make a form from a parameter query. It worked great and I was really excited because this will be invaluable for the semester project I'm doing. I then put a command button on a form previously created (using the wizard) that should open the new form (and thus request that the parameter be entered). Well, I got the blasted "Ambiguous Name Detected: AddNewClick" error message. For one thing, on click, it's supposed to open the form, not add a new record!
Then, when I tried to go back and use the new form by itself, I got a compile error when I tried to close the form using the "close" button ("Compile Error: Ambiguous Name Detected: AddNew_Click"). Same type problem as before -- on click, it's supposed to CLOSE the form, not add a new record.

Since I don't know the language, Access showing me the "problem" doesn't solve a thing. Is there a bug in Access that causes this problem on occasion? Because this isn't the first time I've had the same problem with a form or forms that previously worked. What on earth could be the problem?

Just for info, I’m working on a end-of-chapter problem for my Access 2000 class. The problem involves a computer store's database and I need to be able to click on a button in the "Order Form" to open the "Customer Form" to find/add a customer. I need to be able to do this stuff for my semester project, which will be a client database. I have just over a week before I have to have it done and if I can't get even the homework to work then I'm sunk.

Can anyone provide any tips/insight as to what I can do to try to fix the problem I'm having with the forms in the homework problem?
 
I went and checked out the other message you recommended and then went and looked at the database again.

The problem seems to be that when I click on a button, it sees it only as AddNew and not as anything else. If I click on Close Form, I get the error message and the debugger pops up pointing at AddNew.

I only have one each of OpenForm, AddNew, or CloseForm. Why does it only point to AddNew?

The way I fixed this before was to totally start over -- and that would be a major pain and there's still no guarantee the same thing won't happen.
 
I suspect that the buttons have the same name open the form in design view click on the code button on the toolbar, you should have three separate buttons called, OpenForm_Click, CloseForm_Click and AddNew_Click it sound as if yours has the same name for each button. Check to see if the actual codes for the buttons a different they should contain something like Do.Cmd. OpenForm etc, DoCmd.Close etc, post back if not.
HTH
 
Rich,

I actually went back and deleted all of the buttons, then added a new "OpenForm" button. I still get the same error (AddNew). I also went and checked the code as you suggested and, sure enough, it goes right to Private Sub AddNew_Click().

This is the code I get when I click on the Code button:

Private Sub FindCustomer_Click()
On Error GoTo Err_FindCustomer_Click

Dim stDocName As String

stDocName = "Last Name Parameter"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_FindCustomer_Click:
Exit Sub

Err_FindCustomer_Click:
MsgBox Err.Description
Resume Exit_FindCustomer_Click

End Sub
Private Sub AddNew_Click()
On Error GoTo Err_AddNew_Click


DoCmd.GoToRecord , , acNewRec

Exit_AddNew_Click:
Exit Sub

Err_AddNew_Click:
MsgBox Err.Description
Resume Exit_AddNew_Click

End Sub
Private Sub CloseForm_Click()
On Error GoTo Err_CloseForm_Click


DoCmd.Close

Exit_CloseForm_Click:
Exit Sub

Err_CloseForm_Click:
MsgBox Err.Description
Resume Exit_CloseForm_Click

End Sub
Private Sub OpenCustForm__Click()
On Error GoTo Err_OpenCustForm__Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Super Store Customer Form"

stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenCustForm__Click:
Exit Sub

Err_OpenCustForm__Click:
MsgBox Err.Description
Resume Exit_OpenCustForm__Click

End Sub
Private Sub AddNew_Click()
On Error GoTo Err_AddNew_Click


DoCmd.GoToRecord , , acNewRec

Exit_AddNew_Click:
Exit Sub

Err_AddNew_Click:
MsgBox Err.Description
Resume Exit_AddNew_Click

End Sub
Private Sub CloseForm_Click()
On Error GoTo Err_CloseForm_Click


DoCmd.Close

Exit_CloseForm_Click:
Exit Sub

Err_CloseForm_Click:
MsgBox Err.Description
Resume Exit_CloseForm_Click

End Sub
Private Sub OpenForm_Click()
On Error GoTo Err_OpenForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Super Store Customer Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenForm_Click:
Exit Sub

Err_OpenForm_Click:
MsgBox Err.Description
Resume Exit_OpenForm_Click

End Sub
Private Sub OpenForm_Click()
On Error GoTo Err_OpenForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Super Store Customer Form"

stLinkCriteria = "[LastName]=" & "'" & Me![LastName] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenForm_Click:
Exit Sub

Err_OpenForm_Click:
MsgBox Err.Description
Resume Exit_OpenForm_Click

End Sub
 
Your code appears to be correct,have you got more than one reference to AddNew, deleting the buttons does not remove the code only the button remove all but one sub for each button and make sure your code is compiled, if that doesn't work copy the form rename it, delete the original and rename the copy back to the original, if that doesn't work try importing all your database into a new blank one, remember to compact it after compiling and saving all modules.
HTH

[This message has been edited by Rich (edited 04-14-2001).]
 

Users who are viewing this thread

Back
Top Bottom