Enter more than one parameter value

  • Thread starter STELL via AccessMonster.com
  • Start date
S

STELL via AccessMonster.com

I would like to know how to enter several parameter values to produce several
reports/forms instead of just one. Example: to produce a form, the user gets
prompted to "Enter Fixed Asset Number that needs a Form 140." How can I set
it up to generate several forms instead of one.
 
S

STELL via AccessMonster.com

STELL said:
I would like to know how to enter several parameter values to produce several
reports/forms instead of just one. Example: to produce a form, the user gets
prompted to "Enter Fixed Asset Number that needs a Form 140." How can I set
it up to generate several forms instead of one.

This is what I have on the SQL:

SELECT RoomIDs.ROOM_DESCRIPTION, RoomIDs.ROOM_ID, IBWCInventory.FA_NO,
IBWCInventory.BETT_NO, IBWCInventory.DESCRIPTION, IBWCInventory.MAKE,
IBWCInventory.MODEL, IBWCInventory.SERIAL_NO, IBWCInventory.ACQCOST,
IBWCInventory.PO_NO, IBWCInventory.RECD, IBWCInventory.SUBLOCATION,
IBWCInventory.FSC, IBWCInventory.EQ_TYPE, IBWCInventory.IBWC140
FROM Building INNER JOIN (RoomIDs INNER JOIN IBWCInventory ON RoomIDs.ROOM_ID
= IBWCInventory.ROOM_ID) ON Building.BLDG_CODE = RoomIDs.BLDG_CODE
WHERE (((IBWCInventory.FA_NO) Like "*" & [Enter FA that needs a Form 140]));
 
S

STELL via AccessMonster.com

STELL said:
I would like to know how to enter several parameter values to produce several
reports/forms instead of just one. Example: to produce a form, the user gets
prompted to "Enter Fixed Asset Number that needs a Form 140." How can I set
it up to generate several forms instead of one.

This is what I have on the SQL:

SELECT RoomIDs.ROOM_DESCRIPTION, RoomIDs.ROOM_ID, IBWCInventory.FA_NO,
IBWCInventory.BETT_NO, IBWCInventory.DESCRIPTION, IBWCInventory.MAKE,
IBWCInventory.MODEL, IBWCInventory.SERIAL_NO, IBWCInventory.ACQCOST,
IBWCInventory.PO_NO, IBWCInventory.RECD, IBWCInventory.SUBLOCATION,
IBWCInventory.FSC, IBWCInventory.EQ_TYPE, IBWCInventory.IBWC140
FROM Building INNER JOIN (RoomIDs INNER JOIN IBWCInventory ON RoomIDs.ROOM_ID
= IBWCInventory.ROOM_ID) ON Building.BLDG_CODE = RoomIDs.BLDG_CODE
WHERE (((IBWCInventory.FA_NO) Like "*" & [Enter FA that needs a Form 140]));
 
S

STELL via AccessMonster.com

STELL said:
[quoted text clipped - 11 lines]
= IBWCInventory.ROOM_ID) ON Building.BLDG_CODE = RoomIDs.BLDG_CODE
WHERE (((IBWCInventory.FA_NO) Like "*" & [Enter FA that needs a Form 140]))

Sorry, This problem has been solved. I went to search for other posts and I
found one that was similar to the one I posted. I just altered it a little
bit and it worked. I really like this forum. Very informative.
 
S

STELL via AccessMonster.com

STELL said:
I would like to know how to enter several parameter values to produce several
reports/forms instead of just one. Example: to produce a form, the user gets
[quoted text clipped - 11 lines]
= MyInventory.ROOM_ID) ON Building.BLDG_CODE = RoomIDs.BLDG_CODE
WHERE (((IBCInventory.FA_NO) Like "*" & [Enter FA that needs a Form 140]))

Sorry, This problem has been solved. I went to search for other posts and I
found one that was similar to the one I posted. I just altered it a little
bit and it worked. I really like this forum. Very informative.

for those of you that want to know what I did...I modified the last statement
as follows:
WHERE InStr("," & [Enter FA numbers that need Form 140 (Example: 17339,17410,
17337):] & ",", "," & MyInventory.FA_NO & ",") > 0;
 
S

STELL via AccessMonster.com

STELL said:
I would like to know how to enter several parameter values to produce several
reports/forms instead of just one. Example: to produce a form, the user gets
prompted to "Enter Fixed Asset Number that needs a Form 140." How can I set
it up to generate several forms instead of one.

This is what I have on the SQL:

SELECT RoomIDs.ROOM_DESCRIPTION, RoomIDs.ROOM_ID, MyInventory.FA_NO,
MyInventory.BETT_NO, MyInventory.DESCRIPTION, MyInventory.MAKE,
MyInventory.MODEL, MyInventory.SERIAL_NO, MyInventory.ACQCOST,
MyInventory.PO_NO, MyInventory.RECD, MyInventory.SUBLOCATION,
MyInventory.FSC, MyInventory.EQ_TYPE, MyInventory.My140
FROM Building INNER JOIN (RoomIDs INNER JOIN MyInventory ON RoomIDs.ROOM_ID
= MyInventory.ROOM_ID) ON Building.BLDG_CODE = RoomIDs.BLDG_CODE
WHERE (((MyInventory.FA_NO) Like "*" & [Enter FA that needs a Form 140]));
 
S

STELL via AccessMonster.com

STELL said:
This is what I have on the SQL:

SELECT RoomIDs.ROOM_DESCRIPTION, RoomIDs.ROOM_ID, MYInventory.FA_NO, MYInventory.BETT_NO, MYInventory.DESCRIPTION, MYInventory.MAKE, MYInventory.MODEL, MYInventory.SERIAL_NO, MYInventory.ACQCOST, MYInventory.PO_NO, MYInventory.RECD, MYInventory.SUBLOCATION, MYInventory.FSC, MYInventory.EQ_TYPE, MYInventory.MY140
FROM Building INNER JOIN (RoomIDs INNER JOIN MYInventory ON RoomIDs.ROOM_ID =
MYInventory.ROOM_ID) ON Building.BLDG_CODE = RoomIDs.BLDG_CODE
WHERE (((MYInventory.FA_NO) Like "*" & [Enter FA that needs a Form 140]));
 
G

Guest

Normally to return a set of rows based on a value list you'd use the IN
operator. Unfortunately this does not accept a parameter as its argument,
however. A number of ways of simulating it have been produced, which you'll
find at:


http://support.microsoft.com/kb/100131/en-us


If you use the Inparam and GetToken functions for instance the WHERE clause
of the query would be like this:

WHERE InParam([FA_NO],[Enter FA numbers as a list separated by commas:]) =
TRUE

However, you might like to consider an alternative approach which does not
involve the use of any parameters in the query. For this create an unbound
dialogue form and add a list box, lstFANumbers say, to it which lists all FA
numbers in order. Set the list box's MultiSelect property to either Simple
or Extended as preferred.

Add a command button to the form to open your report or form (or two
button's, one for each) based on the query (now with no parameters). The
code for this, to open a form called frmRooms, would be:

Dim varItem As Variant
Dim strFANumbersList As String
Dim strCriteria As String
Dim ctrl As Control

Set ctrl = Me.lstFANumbers

' loop through list box's ItemsSelected collection
' and build comma separated list of selected items
If ctrl.ItemsSelected.Count > 0 Then
For Each varItem In ctrl.ItemsSelected
strFANumbersList = strFANumbersList & "," & ctrl.ItemData(varItem)
Next varItem

' remove leading comma
strFANumbersList = Mid(strFANumbersList, 2)

strCriteria = "FA_NO In(" & strFANumbersList & ")"

DoCmd.OpenReport "rptRooms", _
View:=acViewPreview, _
WhereCondition:=strCriteria
Else
MsgBox "No FA Numbers Selected", vbInformation, "Warning"
End If

The above assumes that the FA_NO column is a number data type. If it’s a
text data type amend the code as follows to wrap each value in quotes:

For Each varItem In ctrl.ItemsSelected
strFANumbersList = strFANumbersList & ",""" & ctrl.ItemData(varItem)
& """"
Next varItem

If you also want a button on the form to clear all the selections in the
list box use the following code for its Click event procedure:

Dim n As Integer

For n = 0 To Me.lstFANumbers.ListCount - 1
Me.lstFANumbers.Selected(n) = False
Next n

Ken Sheridan
Stafford, England
 
S

STELL via AccessMonster.com

Thanks to your response...I liked the kb link that you referred me to. I
tried it on a sample db. It is good. As for the rest of the suggestions,
I'm not quite there yet to implement all of what you suggested. I'm still
learning...

Ken said:
Normally to return a set of rows based on a value list you'd use the IN
operator. Unfortunately this does not accept a parameter as its argument,
however. A number of ways of simulating it have been produced, which you'll
find at:

http://support.microsoft.com/kb/100131/en-us

If you use the Inparam and GetToken functions for instance the WHERE clause
of the query would be like this:

WHERE InParam([FA_NO],[Enter FA numbers as a list separated by commas:]) =
TRUE

However, you might like to consider an alternative approach which does not
involve the use of any parameters in the query. For this create an unbound
dialogue form and add a list box, lstFANumbers say, to it which lists all FA
numbers in order. Set the list box's MultiSelect property to either Simple
or Extended as preferred.

Add a command button to the form to open your report or form (or two
button's, one for each) based on the query (now with no parameters). The
code for this, to open a form called frmRooms, would be:

Dim varItem As Variant
Dim strFANumbersList As String
Dim strCriteria As String
Dim ctrl As Control

Set ctrl = Me.lstFANumbers

' loop through list box's ItemsSelected collection
' and build comma separated list of selected items
If ctrl.ItemsSelected.Count > 0 Then
For Each varItem In ctrl.ItemsSelected
strFANumbersList = strFANumbersList & "," & ctrl.ItemData(varItem)
Next varItem

' remove leading comma
strFANumbersList = Mid(strFANumbersList, 2)

strCriteria = "FA_NO In(" & strFANumbersList & ")"

DoCmd.OpenReport "rptRooms", _
View:=acViewPreview, _
WhereCondition:=strCriteria
Else
MsgBox "No FA Numbers Selected", vbInformation, "Warning"
End If

The above assumes that the FA_NO column is a number data type. If it’s a
text data type amend the code as follows to wrap each value in quotes:

For Each varItem In ctrl.ItemsSelected
strFANumbersList = strFANumbersList & ",""" & ctrl.ItemData(varItem)
& """"
Next varItem

If you also want a button on the form to clear all the selections in the
list box use the following code for its Click event procedure:

Dim n As Integer

For n = 0 To Me.lstFANumbers.ListCount - 1
Me.lstFANumbers.Selected(n) = False
Next n

Ken Sheridan
Stafford, England
I would like to know how to enter several parameter values to produce several
reports/forms instead of just one. Example: to produce a form, the user gets
prompted to "Enter Fixed Asset Number that needs a Form 140." How can I set
it up to generate several forms instead of one.
 
S

STELL via AccessMonster.com

I'm trying the code right now... I hope it works!
Thanks to your response...I liked the kb link that you referred me to. I
tried it on a sample db. It is good. As for the rest of the suggestions,
I'm not quite there yet to implement all of what you suggested. I'm still
learning...
Normally to return a set of rows based on a value list you'd use the IN
operator. Unfortunately this does not accept a parameter as its argument,
[quoted text clipped - 69 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top