PDA

Click to See Complete Forum and Search --> : Passing parameters to a query


maunded
May 26th, 2004, 08:12 PM
I have a problem passing a parameter to a form which runs a query. I have a list box, which is multi-select, but when a user double clicks on it, it opens a fom which runs a query based on the item the user double clicked on. Below is the code for the double click...

Private Sub Usernames_Box_DblClick(Cancel As Integer)

Dim stDocName As String
Dim stLinkCriteria As String
Dim stUsername As String
Dim stSelected As String

stDocName = "CUSTOMERS_USERNAME_FORM"
stSelected = Me![Usernames_Box].ItemsSelected(0)
stUsername = Me![Usernames_Box].ItemData(stSelected)
stLinkCriteria = "[SelectedUsername]=" & "'" & stUsername & "'"
DoCmd.OpenForm stDocName, acNormal, stLinkCriteria
End Sub

This opens the form OK, but the query.....

SELECT ST_USERNAME_CONFIG.Username, ST_USERNAME_CONFIG.Password,
ST_USERNAME_CONFIG.ReqPoll,
ST_USERNAME_CONFIG.ViewHistory,
ST_USERNAME_CONFIG.SentHistory,
ST_USERNAME_CONFIG.SendText,
ST_USERNAME_CONFIG.TermConfig,
ST_USERNAME_CONFIG.TermAlarm, ST_USERNAME_CONFIG.CustomerImage,
ST_USERNAME_CONFIG.NumberofLogin
FROM ST_USERNAME_CONFIG
WHERE (ST_USERNAME_CONFIG.Username)=[SelectedUsername]
ORDER BY ST_USERNAME_CONFIG.Username;

Asks for the SelectedUsername parameter.

This used to work OK, until I changed the Usernames_Box to a multiselect box (which I need for another function...which is working OK btw :)

Can anyone see what I have done wrong here?

Thanks
Dean.