runtime error 2450

I

inchong

I have a preview button(cmdbutton) in a form. when i click this button
it suppose to bring a different form( i call this mainform(check the
below code)). But that didn't happen. so i checked Mainform code and
had a problem on this line.
CurrentDB = Forms![MainForm]![subform].Form![DatabaseName] with
runtime error 2450 msg.
When i output CurrentDB and it was showing ""
but ssal displayed the right db. with other strings.

Private Sub Form_Open(Cancel As Integer)
Dim CurrentDB As String, ssql As String, MyFilter As String
'Stop
CurrentDB = Forms![MainForm]![subform].Form![DatabaseName]
ssql = "SELECT * FROM DOCUMENTS IN "
ssql = ssql & "'" & CurrentDB & "'"

is there anything wrong in syntax?
does anyone has any idea what i did wrong here.
everytime i open this MainForm i get runtime error 2450.
it says that MS ACCESS cannot find the form "MainForm" ~~~~~~ in VB
code.

Please help me.
 
R

Ray C

The first thing I notice is that you use the variable CurrentDb. That's a
reserved variable in Access. Maybe that's the problem. Try another.
 

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