I have a problem with opening a form.

G

Guest

On the double click event of a button, I have the following code

DoCmd.SetWarnings False

DoCmd.OpenQuery "Qry CustApp", acNormal, acEdit
DoCmd.OpenQuery "List Append", acNormal, acEdit
DoCmd.OpenQuery "List Delete", acNormal, acEdit

DoCmd.OpenForm "Queries Edit form", , , "QueryID = " & Me.QueryID & ""
DoCmd.Close acForm, "menu", acSaveNo

The button is on each row of a continuous form. When I double click the
button it should run the queries and then open the edit form at the record
that I choose.

It has worked in the past but now I get a "missing operator" syntax error
and I can't think why it has doesn't work. The queryID is a number.
 
G

Guest

Hi

Rempve the & "" from the end of the OpenForm line so it reads...

DoCmd.OpenForm "Queries Edit form", , , "QueryID = " & Me.QueryID

Regards

Andy Hull
 
G

Guest

Hmmm, weird. The answer that Andy gave should work. If it's a number you
don't need the apostroph so...

Just to do some checking to see where the error is coming from replace the
me.qeuryID with a hardcoded number like say 6 or something like that. See if
the code runs. If it does we know where the problem is...
 
G

Guest

Hi again

Sounds like it may be something in the form being opened.

What's in that form's on open event?

Regards

Andy
 
G

Guest

Hello,

I don't have anything, but I tried Maurice's idea and put in a number and it
works fine.

DoCmd.OpenForm "Queries Edit form", , , "QueryID = 6"
DoCmd.Close acForm, "menu", acSaveNo
 
G

Guest

Hello, I have tried your suggestion

DoCmd.OpenForm "Queries Edit form", , , "QueryID = 6"

It works ok.
 
G

Guest

Can you tell us what it is you did? I'm curious as to why the hardcoded
solution did work and Andy's solution didn't. My guess was that his answer
seemed correct. Don't get me wrong I'm glad you got it to work just curious
how you did it (and ofcourse others might benefit from it ;-)
 
G

Guest

What I had was a bit complicated and was more of a design fault than code
problem.

I had two tables and I was using the button to transfer records from one
table to another and then open the form for the specific record number. I am
wondering whether the database was getting confused with the field names.

Now I have simplified it so I have a checkbox and using it to filter records
for various subforms.
 

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