Updating Table Data

BrandonM30

New member
Local time
Today, 04:24
Joined
Sep 16, 2016
Messages
9
Hi guys,

I have the following code to call Data from a table and insert it into a form.

Private Sub cmbSONumber_AfterUpdate()

Dim DB As Database
Dim rs As Recordset
Dim STR As String
Set DB = CurrentDb

STR = "SELECT * FROM [tblShippingLog] WHERE [ISF V3 SO] = '" & Me.cmbSONumber & "';"

Set rs = DB.OpenRecordset(STR)
If rs.EOF = False Then
Me.txtShippedBy = rs![Shipped By]
Me.txtProgram = rs![Program]
Me.txtSTSN = rs![ST Serial Number]
Me.txtS3Update = rs![S3 Done]
Me.txtDateCreated = rs![Date Created]
Me.txtDateRequired = rs![Date Required]
Me.txtShipmentDescription = rs![Shipment Description]
Me.txtShipmentNetworkID = rs![Network ID]
Me.txtDeliveryLocation = rs![Delivery Location]
Me.txtGovtTag = rs![Gov Tag]
Me.txtSecurityLevel = rs![CCI/COMSEC or Classified]
Me.txtODTNumber = rs![ODT#]
Me.txtCarrier = rs![Carrier]
Me.txtTrackingNumber = rs![Tracking Info]
Me.txtQTY = rs![Qty]
Me.txtPackageType = rs![Package Type]
Me.textDimensions = rs![Dimensions]
Me.txtWeight = rs![Total Weight]
Me.txtShippingCost = rs![Est# Cost]
Me.txtSTRemarks = rs![Comments]
Me.txtDateShipped = rs![Ship date]
Me.cmbStatus = rs![Status]

End If
rs.Close
End Sub

I would like to then update the fields in the form and inset the new values into the tables record that I chose Initially.

How would I go about doing that? Do I use an Update Query?

Thanks in advance for your help and assistance.
 
Why not just use a bound form? What does this method allow you to do that using a bound form doesn't?

Also, you really need to be accurate in the terms you use:

ld like to then update the fields in the form and inset the new values into the tables record that I chose Initia

UPDATE and INSERT are two different actions. Which one do you want to do? UPDATE edits an existing record in a table. INSERT adds a new record to a table.

Again though, bound forms are probably the way to do this.
 

Users who are viewing this thread

Back
Top Bottom