G
Guest
Hi everyone
I am working on a form that has a list box control of items, the
functionality that I need to add is that when the user double cliks on one
item of the list box the other controls that I have on my form should
autopopulate.
This listbox has InquiryId's which are the primary key of my table inquiries.
I am fairly new coding but so far this is what I've tried:
P.S.: "ViewInquiries" is the name of my listbox on the form, and the
"AccessNSUnionInquiries" that I am using on the Select Stament is a query.
Private Sub ViewInquiries_DblClick(Cancel As Integer)
Dim rs As Recordset
Dim strSQL As String
Dim db As DAO.Database
Dim sArgs As String
For Each row In Me.ViewInquiries.ItemsSelected
sArgs = Me.ViewInquiries.Column(1, row)
Next row
sArgs = "Form=" & Me.Name & ";" & _
"InquiryID=" & sArgs & ";"
Set db = CurrentDb
strSQL = "SELECT * FROM AccessNSUnionInquiries" & _
"WHERE Inquiries.InquiryID = sArgs;"
Set rs = CurrentDb.OpenRecordset(strSQL)
With rs
Me.accessNSID = .Fields("RacfID")
Me.FirstName = .Fields("FirstName")
Me.LastName = .Fields("LastName")
Me.Email = .Fields("Email")
Me.Company = .Fields("Company")
Me.City = .Fields("City")
Me.State = .Fields("State")
Me.ProblemName = .Fields("ProblemCategory")
Me.ProblemDescription = .Fields("ProblemType")
Me.Terminal = .Fields("Terminal")
Me.Train = .Fields("TrainNo")
Me.Day = .Fields("Day")
Me.Unit = .Fields("Unit")
Me.Comments = .Fields("Comments")
Me.Frame = .Fields("Source")
End With
rs.Close
Set rs = Nothing
Me.Requery
db.Close
Set db = Nothing
End Sub
I don't even know if this code is close to being correct, I will provide
more details if needed, I would greatly appreciate any help!
I am working on a form that has a list box control of items, the
functionality that I need to add is that when the user double cliks on one
item of the list box the other controls that I have on my form should
autopopulate.
This listbox has InquiryId's which are the primary key of my table inquiries.
I am fairly new coding but so far this is what I've tried:
P.S.: "ViewInquiries" is the name of my listbox on the form, and the
"AccessNSUnionInquiries" that I am using on the Select Stament is a query.
Private Sub ViewInquiries_DblClick(Cancel As Integer)
Dim rs As Recordset
Dim strSQL As String
Dim db As DAO.Database
Dim sArgs As String
For Each row In Me.ViewInquiries.ItemsSelected
sArgs = Me.ViewInquiries.Column(1, row)
Next row
sArgs = "Form=" & Me.Name & ";" & _
"InquiryID=" & sArgs & ";"
Set db = CurrentDb
strSQL = "SELECT * FROM AccessNSUnionInquiries" & _
"WHERE Inquiries.InquiryID = sArgs;"
Set rs = CurrentDb.OpenRecordset(strSQL)
With rs
Me.accessNSID = .Fields("RacfID")
Me.FirstName = .Fields("FirstName")
Me.LastName = .Fields("LastName")
Me.Email = .Fields("Email")
Me.Company = .Fields("Company")
Me.City = .Fields("City")
Me.State = .Fields("State")
Me.ProblemName = .Fields("ProblemCategory")
Me.ProblemDescription = .Fields("ProblemType")
Me.Terminal = .Fields("Terminal")
Me.Train = .Fields("TrainNo")
Me.Day = .Fields("Day")
Me.Unit = .Fields("Unit")
Me.Comments = .Fields("Comments")
Me.Frame = .Fields("Source")
End With
rs.Close
Set rs = Nothing
Me.Requery
db.Close
Set db = Nothing
End Sub
I don't even know if this code is close to being correct, I will provide
more details if needed, I would greatly appreciate any help!