Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

After update list box, making global string? 1

Status
Not open for further replies.

Egglar

Technical User
Apr 4, 2002
88
0
0
GB
Hi,

Im not sure if I have the terminology correct, but heres the situation.

I have a list box on a form, when the user selects dates in the list box, the after update event creates part of an sql string, and adds it on, known as MonthSql. The sql output looks something like this: 01/01/03 OR 01/02/03 OR 01/03/03 etc etc depending on what the user selects.

MonthSql is then added on the end of two sql strings, a select and update. These strings then need to be executed when a command button is clicked.

The problem I’m having is making the MonthSql string global to be available in either a module function, or a command button.

If I debug.print monthsql in a function, or on a command button it isn’t showing the string at all, so I guess other objects cant see the string because its in the afterupdate event of the list box..

Question is, how can I make the string monthsql available to other objects? I don’t want to go down the route of creating a query in the sys table and then executing it etc, id rather use currentdb.execute(selectsql) etc.

Thanks in advance. Elliot.
 
Hi,
I hope I'm interpreting you correctly.. By the sounds of it you just need a Public variable.

Declare MonthSql in a Module as:

Public MonthSql as String

This variable will have public scope & will be viewable from Forms AND Modules etc.

HTH,
Patrick
 
Apologies for late reply!

That worked a treat, i thought it was something like that but i couldnt work it out.

Many thanks.
 
hello egglar!

i noticed that you build some sql from your list box.

i too want to use the after update to create an "X or Y or Z or..." string but cant seem to figure it out.

all i need is the correct syntax and ill be away laughing.

im lost at the question marks

for this selection blah blah
TextToBeAddedtoSQLString = me.ThisList.??????
SQLString = SQLString & " or " & TextToBeAddedtoSQLString
next selection blah blah

any help would be appreciated

a quick glance at the code for this event is probably all i need.

cheers

Mike C
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top