Author |
Topic |
PETE314
Starting Member
37 Posts |
Posted - 2004-10-05 : 08:32:03
|
I have an Access .mdb that I am switching to an Access Project .adp. One of the forms I have created is a simple selection box where you select from a list from one listbox(a) and send those selections to another listbox(b). Once all needed are selected then I can run code based upon those records within listbox(b). The problem is this. I have dealt mainly in VBA and Access and I am making the transition into Transact SQL,Stored Procedures and the like. So I am going to have many stumbling blocks along the way....lol. As an Access .mdb I used temptables to hold the information within each listbox. I figured temptables would be ideal in SQL especially since in a multi-user environment each connection has their own set. I would not have to worry about naming conventions such as XXXXtemptblname where XXXX is a random number generated. However I am having trouble linking the source for the listboxes to a SQL temptable. I have tried to do so thru ADO but I am still unsuccessful.How can I link the listboxes to SQL temptables????Will it be better to create and drop tables with naming conventions instead of temptables????Is there a better way of creating a form like this????Thank you for any help in this matter. |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2004-10-05 : 09:51:53
|
Why not just put the selected items from the first listbox into a recordset and then run code based on the recordset or populate the second listbox from the recordset?? |
 |
|
PETE314
Starting Member
37 Posts |
Posted - 2004-10-05 : 10:14:54
|
quote: Originally posted by RickD Why not just put the selected items from the first listbox into a recordset and then run code based on the recordset or populate the second listbox from the recordset??
Your talking about using ADO???Create a recordset query in code and then set the record source for the listbox(es) to that recordset???? I have tried this except that it is not working....I am getting errors when I open the form. I create the code on the OnOpen event for the form...and yet the listboxes still ask for recordset saying that the current recordset is not available or is spelled incorrectly. |
 |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2004-10-05 : 10:38:49
|
Yeah, i'm talking about ADO...Do you mean that you are trying to populate the second listbox on the start of the form?? With what are you trying to populate it exactly?? You said that this was user selected, so it shouldn't be populated until the user has selected something out of the first listbox surely?!? You actually want to create the code for this population in the OnChange event of the first listbox and to set the second listbox to not have a source... |
 |
|
PETE314
Starting Member
37 Posts |
Posted - 2004-10-05 : 11:05:51
|
quote: Originally posted by RickD Yeah, i'm talking about ADO...Do you mean that you are trying to populate the second listbox on the start of the form?? With what are you trying to populate it exactly?? You said that this was user selected, so it shouldn't be populated until the user has selected something out of the first listbox surely?!? You actually want to create the code for this population in the OnChange event of the first listbox and to set the second listbox to not have a source...
right.....listbox(a) is supposed to be populated.......listbox (b) does not have a source until they press the button to transfer the selected names from listbox (a) However either something continues to remain in the rowsource from previous....or something else....I am getting errors stating that the stuff to populate listbox (a) is not there or spelled incorrectly. and THEN it runs the OnOpen code to populate the listbox (a) and set its record source. Its as if the listboxes are initialized before the ONOpen event for the form...and something is straggling behind trying to link the listboxes to something. |
 |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2004-10-06 : 06:12:11
|
The listboxes are tried to populate before the form is opened.. You may want to put your code in the OnLoad event to populate listbox(a)... Not sure about why it should be trying to populate the listbox when there is no rowsource set, you may have an extraneous reference somewhere?!? Make sure you haven't set it in more than one place...Obviously lisbox(b) should be populated from the code behind the button... |
 |
|
PETE314
Starting Member
37 Posts |
Posted - 2004-10-06 : 07:38:50
|
Thanks Rick, I didn't think about OnLoad event (why, I don't know...lol)I will give it a shot....I keep trying to find something that it is trying to link to in the properties...but everything is blank....So I am now combing code to make sure I don't have something really strange and weird running at the same time.Again thanks for the help. |
 |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2004-10-06 : 07:52:42
|
Are you sure you haven't got a Record Source set at the form level?? If not then I guess it must be in your code somewhere... |
 |
|
PETE314
Starting Member
37 Posts |
Posted - 2004-10-06 : 09:00:55
|
quote: Originally posted by RickD Are you sure you haven't got a Record Source set at the form level?? If not then I guess it must be in your code somewhere...
It is an unbound form.....I have found a new book that I believe is going to help me tremendously. It deals with this exact problem. It is showing a few workarounds to populate unbound combo and list boxes in an Access Project. So If I come up with a solution I will post what worked for me..... |
 |
|
|