• Thread starter Thread starter Richard Wood
  • Start date Start date
R

Richard Wood

I want to run an update query from within a form page, but
only update the details of the record I am currently
looking at. It seems to be possible to select the same
record when opening another form using the condition part
of the openform command, but this isn't available for
openquery.

Any suggestions, or can someone point me to a place to
find this out

Thanks
 
you can use the docmd.openquery command.
Write the update query in design mode. include all field
in the table. then in the criterai pane put
[forms].[your form name].[control name]
do this for all fields in the query. when run with the
docmd.openquery command this will update all the fields in
the table with info from the forms controls.
if you don't want a seperate query, you can put the query
code in the form. open the update query that you wrote in
design mode then view SQL. copy the SQL. then on the form
put a button. right click the button>build events>code.
in the button's sub put the docmd.runsql command. it
should look something like this
Sub button_click()
DoCmd.RunSQL "first line of sql " & _
"second line of sql " & _
"third line of sql;"
end sub
make note of the continuation characters- important if
your sql wraps.
 
Back
Top