Link to home
Start Free TrialLog in
Avatar of GPSPOW
GPSPOWFlag for United States of America

asked on

Appending new record to Access Table from Form Input

I have created a two page form in Access to acquire user input on patient surgical infection outcomes.  it has about 30 fields to be entered yes/no or with a comment.

I have a Table with a field to accept the data from every field on the form,


Form Field= ChkVomit     Y/N format           Table Field = Vomit  Y/N format

What would the syntax be to Insert Into the TABLE from the FORM fields?

Thanks

Glen
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

If your form is bound to that table (i.e. the form's record source property is your table name), then you can map the columns to each textbox using the Row Source property.

Pull that off and you won't need to create a separate query to handle the INSERT.
Avatar of GPSPOW

ASKER

Form is not bound to the Destination table.

Glen
UPDATE yrtable
SET     fieldname = Me!chkVomit
WHERE tableID = me!fieldwithtableID

Kelvin
<No pints wanted>

In other words, you can use the form wizard to create your form.
Select your table as the forms source...
...Then follow the rest of the wizards steps

JeffCoachman
Avatar of GPSPOW

ASKER

So it would be:

Update tblSSIInput
Set SIP = me.ChkSIP
Set SIS = me.ChkSIS
Set PURULENT = me.ChkPur
Set VOMITING = me.ChkVomit
Set COMMENT_ORGAN = me.txtOrg


Do I need the "WHERE" clause?
All the data is coming from the FORM fields.

Thanks

Glen
Update tblSSIInput
Set SIP = me.ChkSIP,
      SIS = me.ChkSIS,
      PURULENT = me.ChkPur,
      VOMITING = me.ChkVomit,
      COMMENT_ORGAN = me.txtOrg
WHERE ....


Yes you need the where clause or every record in table tblSSIInput will have these fields updates to these values.


Kelvin
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GPSPOW

ASKER

Thanks

After reading more about this, I agree with you.  I will reconfigure my form and approach.

Thanks
To be clear, ...I was not trying to take a way from kelvinsparks' post.
kelvinsparksis perfectly valid if the form needed to be unbound.

There are reasons why an Access form should be unbound, ...but looking at your question, all you were doing was adding records (and probably viewing editing and deleting)

All of this functionality is included in a bound form.

Again, .if you go unbound, you are forced to write code for every user action...

JeffCoachman
I'd agree with Jeff. The bound form solution is the easiest and most practical solution in most cases. I'd assumed that you'd considered and discarded that solution.

Kelvin