clarkcovey
Registered User.
- Local time
- Today, 13:22
- Joined
- Jul 30, 2014
- Messages
- 20
Hello,
I am trying to create a (normally simple) application, but not having a solid grasp on the concepts of recordsets, I find myself floundering. :banghead:
The application is serial number tracking for appliances.
The functionality needs to be able to:
To allow someone to edit, they simply double click on one of those records to open a seperate form and edit.
When I displayed the content of the temporary table in the form for editing, I found it was not updating the original table.
When I create a separate recordset, using the values of the record selected, the recordset appears to be empty, therefore not displaying the correct record for editing.
My main table name is "SerialNumbers". The code below is triggered when the user double clicks on the desired record to edit.
Any advice will be greatly appreciated as I am sure there is probably a much more effective and more simplistic approach to this!
Clark
Private Sub Claim_DblClick(Cancel As Integer)
'*********************************************************************
'* Subroutine to take values from search results for editing record. *
'*********************************************************************
'Initializing variables
Dim ClaimNo, ApplianceName, SerialNo, MakeName, ModelNo, sqlstr As String
' Store values from temporary table "serialSQL" to use for editing
ClaimNo = Claim
ApplianceName = Appliance
SerialNo = Serial
MakeName = Make
ModelNo = Model
'Establishing recordset
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
'Query primary table "SerialNumbers" using values from temporary search table
sqlstr = "SELECT * FROM SerialNumbers WHERE ClaimNumber = '" & ClaimNo & "' and SerialNumber = '" & SerialNo & "'"
Set rs = db.OpenRecordset(sqlstr)
'Test results of recordset
MsgBox ClaimNumber 'ERROR: Currently displays an empty message
'Activate form used for editing results
[Forms]![Serial Number Tracker]![serialEdit].SetFocus
'Update the current record on the form
[Forms]![Serial Number Tracker]![serialEdit].Requery
' END RESULT: The first record of "SerialNumbers" is displayed and can be edited, but it is the wrong record.
End Sub
I am trying to create a (normally simple) application, but not having a solid grasp on the concepts of recordsets, I find myself floundering. :banghead:
The application is serial number tracking for appliances.
The functionality needs to be able to:
- Search for serial numbers using partial strings (i.e. serial # "T12395723K39" can be located by entering "3K3")
- If the serial number does not already exist, allow for adding it.
- If data was added erroneously, allow editing to correct it.
To allow someone to edit, they simply double click on one of those records to open a seperate form and edit.
When I displayed the content of the temporary table in the form for editing, I found it was not updating the original table.
When I create a separate recordset, using the values of the record selected, the recordset appears to be empty, therefore not displaying the correct record for editing.
My main table name is "SerialNumbers". The code below is triggered when the user double clicks on the desired record to edit.
Any advice will be greatly appreciated as I am sure there is probably a much more effective and more simplistic approach to this!
Clark
Private Sub Claim_DblClick(Cancel As Integer)
'*********************************************************************
'* Subroutine to take values from search results for editing record. *
'*********************************************************************
'Initializing variables
Dim ClaimNo, ApplianceName, SerialNo, MakeName, ModelNo, sqlstr As String
' Store values from temporary table "serialSQL" to use for editing
ClaimNo = Claim
ApplianceName = Appliance
SerialNo = Serial
MakeName = Make
ModelNo = Model
'Establishing recordset
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
'Query primary table "SerialNumbers" using values from temporary search table
sqlstr = "SELECT * FROM SerialNumbers WHERE ClaimNumber = '" & ClaimNo & "' and SerialNumber = '" & SerialNo & "'"
Set rs = db.OpenRecordset(sqlstr)
'Test results of recordset
MsgBox ClaimNumber 'ERROR: Currently displays an empty message
'Activate form used for editing results
[Forms]![Serial Number Tracker]![serialEdit].SetFocus
'Update the current record on the form
[Forms]![Serial Number Tracker]![serialEdit].Requery
' END RESULT: The first record of "SerialNumbers" is displayed and can be edited, but it is the wrong record.
End Sub