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

Update a Table form txtbox in form

Status
Not open for further replies.

deadhead7

Programmer
Apr 18, 2003
57
US
How do you update a table from data entered into a textbox on a form. I have a txtbx on a form and a subform of a table one column. I want to enter data into the txtbx and have it entered into the table and see the refreshed data in the subform showing what was just added. Anyone?
 
At the bottom of a form is an arrow pointing right with an asterisck in front of it thats the add record button click that you will get a blank record to add into. You could also put on a button called add record and in that button code it to refresh the table.

that code if mrmory serves is "tablename.refresh" or if you use the arrow and asterisk go to the menu click records then choose refresh.

Cretin
 
I'd suggest putting a command button on the form also that when clicked performs some generic error checking and then adds it to the table and refreshes the subform. As far as the adding and refreshing code:

Code:
Public Sub command1_Click()

Dim dbs as Database
Dim rst as Recordset

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tablename")

If rst.RecordCount > 0 Then
   rst.MoveLast
     With rst
          .Add
               txtbox.SetFocus
               !fieldname = txtbox.Text
          .Update
     End With
End If

Me!subformname.Refresh

End Sub

I think that should take care of it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top