I have an excel sheet with 4 pieces of data I would like to send to an access database. The fields in the database are:
quoteNumber (which is the primary key)
quoteDate
quoteCustomer
quoteProfile
I fill in the spreadsheet then press a command button with the following code:
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase("C:\QuoteDB.mdb")
Set rs = db.OpenRecordset("quoteInfo", dbOpenTable)
rs.AddNew
rs.Fields("quoteNumber") = Me.txtQuoteNumber.Value
rs.Fields("quoteDate") = Me.cboDate.Value
rs.Fields("quoteCustomer") = Me.txtCustomer.Value
rs.Fields("quoteProfile") = Me.cboProfile.Value
rs.Update
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
This works fine if I'm adding a brand new record. How would I loop through to find and overwrite an existing record that matches me.txtQuoteNumber if I wanted to make a change.
Basically, I'm trying to use the spreadsheet everyone already uses to populate the database. Any help or other suggestions are appreciated.
quoteNumber (which is the primary key)
quoteDate
quoteCustomer
quoteProfile
I fill in the spreadsheet then press a command button with the following code:
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase("C:\QuoteDB.mdb")
Set rs = db.OpenRecordset("quoteInfo", dbOpenTable)
rs.AddNew
rs.Fields("quoteNumber") = Me.txtQuoteNumber.Value
rs.Fields("quoteDate") = Me.cboDate.Value
rs.Fields("quoteCustomer") = Me.txtCustomer.Value
rs.Fields("quoteProfile") = Me.cboProfile.Value
rs.Update
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
This works fine if I'm adding a brand new record. How would I loop through to find and overwrite an existing record that matches me.txtQuoteNumber if I wanted to make a change.
Basically, I'm trying to use the spreadsheet everyone already uses to populate the database. Any help or other suggestions are appreciated.