Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report always asks for primary key

Status
Not open for further replies.

jdcurry

Technical User
Dec 11, 2003
2
US
I have a list box that lists a bunch of server names. When i highlight one and click a command button called "Run Report" it always asks for the primary key and when i enter any number it then goes to the report... how do i correct this? Let me know if you need more info,
 
We need more info. What is it supposed to be doing and what does the code look like behind the button?
 
'CODE BEHIND THE BUTTON
Private Sub cmdRun_Click()

Dim strFilter As String
Dim varItem As Variant
' loop through listbox items selected
For Each varItem In Me!lstServers.ItemsSelected
strFilter = strFilter & "[Server_Name] = '" & _
Me![lstServers].ItemData(varItem) & "' OR "
Next ' continue loop
'
' the next bit of code will subtract out the last "OR"
If strFilter <> &quot;&quot; Then
strFilter = Left(strFilter, Len(strFilter) - 4)
Else
MsgBox &quot;You did not select any server(s).&quot;
lstServers.SetFocus
Exit Sub
End If

DoCmd.OpenReport &quot;test&quot;, acPreview, , strFilter

End Sub

------------------------------
Basically what i want is to select a server(s) from a listbox, press run report and it return downtime for that server during business hours which i already have a query to do this called &quot;downtime_business_hrs&quot;

I am fairly new to creating reports off of forms so your help is so very much appreciated!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top