Please Help MultiSelect ListBox!!!!! (1 Viewer)

lorenzoaj

Registered User.
Local time
Today, 07:08
Joined
Nov 26, 2001
Messages
32
I am having a real hard time here and hope someone can help. I am trying to add to my report selections from a listbox. The report opens up but it is empty. I think the problem is that the data is not being sent to the table but I am not sure. I have attached the database because I am having a hard time explaining this. Can someone please look at it and tell me what I am doing wrong. I received the code from this site not sure where and have tried to make it work for me but now I am at a loss. Thanks in advance.

AJ
 

Attachments

  • db1.zip
    41.2 KB · Views: 161

Jack Cowley

Registered User.
Local time
Today, 14:08
Joined
Aug 7, 2000
Messages
2,639
I took a quick look at your db. The "Distribution" field in your table "tblReassignment" is a number Data Type. Your list box is returning Distribution (a Text Data Type), not the ID which is what you want. Create your SQL string and then try using DoCmd.OpenQuery SQL instead of what you have... This is all I have time for but it may give you a start....
 

Alexandre

Registered User.
Local time
Today, 20:08
Joined
Feb 22, 2001
Messages
794
There are two fundamental problems with what you set up:

1. You should have 2 separate forms. 1 bound form to display your records. 1 unbound to let the user pick values in your listbox and open the report.
Having that listbox on the bound form, you create a situation where, in the current record, the value of the field your listbox is based on gets LOST. :eek:
Check it:
-complete all the fields for the first record, directly in your table.
-launch the form and a report.
-go and see in the table: the value got eliminated.

2 You are gathering text values in your code while the field you use as a criteria, based on a lookup table, is in fact a numeric field. Adapt the recordsource query of your listbox to gather two fields: the ID and the description. Then set the properties of the listbox to 2 columns, widths: 0;6 cm (thus hiding the first column), bound column:1.
This will display the descriptions while actually working with the IDs. Then adapt your code to supress all the unecessary Chr(34)

Otherwise your code is pretty good for someone saying he is a begginer. :p

Finally, do not forget to complete your relationships (relationship with the Distribution lookup table is missing) and to inforce relational integrity between your lookup and main tables.
 
Last edited:

Alexandre

Registered User.
Local time
Today, 20:08
Joined
Feb 22, 2001
Messages
794
Jack, concise and to the point...

..beat me at the 'submission contest' as usually ;)
How are you, Jack?
 

lorenzoaj

Registered User.
Local time
Today, 07:08
Joined
Nov 26, 2001
Messages
32
Thank you both very much I will try your suggestions.

Alex,
I wish I could take credit for the code but I can't. The only thing I changed was the SQL statement and I copied that from the SQL View in the query. I do consider myself a beginner because there is so much I am learning every day.

AJ
 

Users who are viewing this thread

Top Bottom