I want to have a program in VB 6 that has a listbox that is filled from an Access db among other controls. I want to be able to pull up a data report based on what is selected in the listbox or the record currently being viewed whichever is easier. I can pull up my data report just fine but there are several clients each having their own data report and they are all in one long report that is basically the same report repeated several times with info particular to each client. I hope that makes sense.
What I would like is to pull up individual reports and have the report pull up that corresponds to the client that is in the listbox. I don't want the report pulled up by clicking on the list box but rather when the user clicks a button. I used this successfully in another program. But don't want to prompt the user for input but rather just click a button and pull up the report for the record that is being viewed.
Private Sub ModuleReport_Click()
If demoduleReport.rsCommand1.State = adStateOpen Then
moduleSN = InputBox("Select a module serial number to view a report on it", "Module Report")
If moduleSN <> "" Then
demoduleReport.Command1 moduleSN I think the change is needed here.
ModuleReport.WindowState = 2
ElseIf moduleSN = "" Then
MsgBox "You haven't entered a valid number", _
vbCritical, "Invalid number"
If I have a list box called lstClient I suppose I need to somehow reference the listindex.
thanks for any help!
See if the following helps:
How To Refresh a Parameterized DataReport
If you want the value of the currently selected item:
Dim strItem As String
strItem = List1.List(List1.ListIndex)