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

Syntax for Updating table

Status
Not open for further replies.

jjones100

Technical User
Nov 12, 2004
23
US
I am currently updating my db via a form using the following code: Forms!FMSUpdate!Message.Value = "Here it is". What is the syntax to update the table directly instead of going through the form. Thanks
 
You could use some code such as this placed on a Save command button:
Private Sub notebox_OnClick()
Dim DB As DAO.Database
Dim RS As DAO.Recordset
Dim strWhere As String

Set DB = CurrentDb()
Set RS = DB.OpenRecordset("YourtableName", dbOpenDynaset)
strWhere = "[PrimaryKey] = " & Me![PrimKeyOnForm]
RS.FindFirst strWhere
If RS.NoMatch Then
MsgBox "No match found"
Else
RS.Edit
RS![FieldToUpdate] = Me![FieldOnForm]
RS.Update
End If
RS.Close
DB.Close
Set RS = Nothing
Set DB = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top