Hi There,
I have a form with a search field for an unique field, that looks up records in the table that belong to that unique field. See Code:
Private Sub cboLastName1_AfterUpdate()
On Error Resume Next
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
cboLastName1.SetFocus
If cboLastName1.Value > 0 Then
strSQL = "SELECT * FROM tbl24HRPolicies WHERE AutoNumber = " & cboLastName1.Value
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
If Not rs.BOF Then
Me.ID = rs("AutoNumber")
Me.Prefix = rs("PolicyNumber")
Me.FirstName = rs("DateReceived")
Me.MiddleName = rs("Comments")
Me.LastName = rs("ClientsName")
Me.Suffix = rs("ShopID")
Me.NickName = rs("Nickname")
Me.Title = rs("ActivePolicy")
End If
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End If
The fields, that take content based on that search field, are unbound.
I've added the delete button, but it's not working, because they are unbound. Is there no way to delete records with this form??
I have a form with a search field for an unique field, that looks up records in the table that belong to that unique field. See Code:
Private Sub cboLastName1_AfterUpdate()
On Error Resume Next
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
cboLastName1.SetFocus
If cboLastName1.Value > 0 Then
strSQL = "SELECT * FROM tbl24HRPolicies WHERE AutoNumber = " & cboLastName1.Value
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
If Not rs.BOF Then
Me.ID = rs("AutoNumber")
Me.Prefix = rs("PolicyNumber")
Me.FirstName = rs("DateReceived")
Me.MiddleName = rs("Comments")
Me.LastName = rs("ClientsName")
Me.Suffix = rs("ShopID")
Me.NickName = rs("Nickname")
Me.Title = rs("ActivePolicy")
End If
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End If
The fields, that take content based on that search field, are unbound.
I've added the delete button, but it's not working, because they are unbound. Is there no way to delete records with this form??