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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete using value from form 1

Status
Not open for further replies.

Sardamil

Programmer
Apr 14, 2001
77
NL
I'm trying to delete records from a table using a selected value on a form. I get an error when running this statement. The messagebox says "parameter missing". Must be a syntax error.

CurrentDb.Execute "DELETE * from [Journalisering BG 09] WHERE ((([Journalisering BG 09].[inhoudingsplichtige])<>[Forms]![Selecteren lusmaand]![Begunstigderelatie]))"

To prevent me from having to ask more questions like this, does anybody have a good website where I can learn the basics for vba? Perhaps tektips has one, but could find it.

Murphy's Law said:
Anything that can go wrong will go wrong

Window to my world
 
There's something wrong with the name of the form. When I use a hardcoded value it works.
Perhaps declare the variabel on the form?

Murphy's Law said:
Anything that can go wrong will go wrong

Window to my world
 
I added this messagebox
MsgBox ([Forms]![Selecteren lusmaand]![Begunstigderelatie]), vbOKOnly, ""
to the code to see if the correct value is picked up from the box. The messagebox shows the correct value.

Murphy's Law said:
Anything that can go wrong will go wrong

Window to my world
 
Changed the code to this

MsgBox ([Forms]![Selecteren lusmaand]![Begunstigderelatie]), vbOKOnly, ""
Dim id_ip
id_ip = [Forms]![Selecteren lusmaand]![Begunstigderelatie]
CurrentDb.Execute "DELETE * from [Journalisering BG 09] WHERE (([Journalisering BG 09].[inhoudingsplichtige])<>id_ip))"

Now I get an error message on "<>id_ip"



Murphy's Law said:
Anything that can go wrong will go wrong

Window to my world
 
You may try this
Code:
CurrentDb.Execute "DELETE * FROM [Journalisering BG 09] WHERE inhoudingsplichtige<>'" & id_ip & "'"
If inhoudingsplichtige is defined as numeric then get rid of the single quotes.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top