Opening form in update mode

  • Thread starter Thread starter bill
  • Start date Start date
B

bill

I need the ability to request record information from the
user, and then open a form to that record and that allows
them to edit exisiting data in a table.

Can this be done, and if so, how?

Thanks
Bill
 
Hi,Bill. Sure, you can do it with the OpenForm method of
the DoCmd object. Syntax is:

DoCmd.OpenForm(FormName, View, FilterName, WhereCondition,
DataMode, WindowMode, OpenArgs)

For your case, let's assume you're requesting information
on a form named frmRecInfo into a control named
cboMatchValue. Resulting VBA is:

DoCmd.OpenForm(<formname to open>, AcFormView,<the
fieldname that matches the user input> = Forms!frmRecInfo!
cboMatchValue,acFormEdit,,)

HTH
Kevin Sprinkel
 
I forgot to mention that you should add the code to some
event procedure. In your case, a command button seems
natural. Turn the wizard on in Form Design mode, add the
command button, and choose Form Operations/Open Form and
choose the form from the list.

After the wizard creates the basic event procedure, modify
it as described.

KGS
 
Thanks. I have attempted to implement this on a command
button, on the form requesting the input from the user.
The problem I seem to be running into is that the
fieldname that matches the user in put is "Survey
Number". It includes the space, which VBA doesnt seem to
like, unless I am not coding it correctly. I am
including my code below for your review.

DoCmd.OpenForm (frmStudyData, acFormView, Study Number
= Form!frmUpdate1!txtUpdate1, acFormEdit,,)


Thanks again
 
Brackets identify the string as a field to Access, as in:

DoCmd.OpenForm (frmStudyData, acFormView, [Study Number]
= Form!frmUpdate1!txtUpdate1, acFormEdit,,)

However, most developers name their fields without spaces
to avoid this issue. Since the user typically only sees
data input forms where you can put more user-friendly
labels on the fields, there is really no negative impact
on the user to employing this convention.

HTH
Kevin Sprinkel
 
Back
Top