Command Button Error (1 Viewer)

amx

Registered User.
Local time
Today, 12:22
Joined
May 5, 2005
Messages
14
Hi,

I have created a command button on a form which quite simply is meant to open a report.

However I get the error, as in the attached image.

Any idea why i'm getting it, and how to get rid?! I just want the button to open a report!

Cheers
amx
 

Attachments

  • access error.jpg
    access error.jpg
    23.9 KB · Views: 130

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 20:22
Joined
Jul 9, 2003
Messages
16,399
Did you use the command button wizard to create the button ?

If not, use the command button wizard and see if that works OK for you.
 

amx

Registered User.
Local time
Today, 12:22
Joined
May 5, 2005
Messages
14
yeah, used the command button wizard...

and also tried deleting it, and then trying again with the events on properties...

still the same...

very confused... and frustrating!

cheers
amx
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 20:22
Joined
Jul 9, 2003
Messages
16,399
Does the report open OK when you click on it?


Post the code Generated by the command button wizard.


Which version of MS Access are you using?
 

amx

Registered User.
Local time
Today, 12:22
Joined
May 5, 2005
Messages
14
yeah, opening the report normally works fine...

using access 2000 (version 9.0)

This is the code the wizard generates...
The button is called 'search' and is to open and preview the report, called rptSearch

.....

Private Sub Search_Click()
On Error GoTo Err_Search_Click

Dim stDocName As String

stDocName = "rptSearch"
DoCmd.OpenReport stDocName, acPreview

Exit_Search_Click:
Exit Sub

Err_Search_Click:
MsgBox Err.Description
Resume Exit_Search_Click

End Sub

....

Cheers

amx
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 20:22
Joined
Jul 9, 2003
Messages
16,399
Do you have a function or module called "rptSearch" ?
 

amx

Registered User.
Local time
Today, 12:22
Joined
May 5, 2005
Messages
14
nope...nothing. and rptSearch is my only report.

I was originally getting an error message relating to 'ambiguous name: Search_Click' (the command button is called Search, and is On Click) - however this isn't the error I am getting anymore! No idea why!

it's very strange!

cheers

amx
 

krberube

just beyond new
Local time
Today, 15:22
Joined
Jan 14, 2005
Messages
142
maybe try to compact and repair then open it again??
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 20:22
Joined
Jul 9, 2003
Messages
16,399
Right , try this .... scrap that command button and the related code. Create new command button with the wizard, this time name it "btnSearch" or "cmdSearch" whichever takes your fancy.

see if that puts it right....
 

amx

Registered User.
Local time
Today, 12:22
Joined
May 5, 2005
Messages
14
Nope that didn't work..

although what did was copying the form as another name, then renaming the original form, and then called the copied form the original name, frmSearch...

Now it all seems to work, from the new copied form... having deleted the old copy..

How incredibly bizarre

Cheers all your your help!!

amx
 

intrep11

Registered User.
Local time
Today, 20:22
Joined
Apr 6, 2003
Messages
63
simular thing

I have suffered a simular issue in the past and solved it the same way as you however it came back it effected what appeared to be random forms in the DB

to solve it for good create a blank DB and import all your DB too it the delete the old one.

I would also check you PC for a macro virus or simular as i found some ambigous code to activiate a dialer in a hidden module.

to date i ahve not been able to find any complete answer to this although i have found many simular questions
ND
 

Users who are viewing this thread

Top Bottom