S
StarfishJoe
I am working on a project for a client.
He has an Access 97 database, (about to be upgraded to Access 2000), that
needs enhancing.
One of the features he wants is a form of text boxes and parameters to sort
and filter on.
The form should build a query that can be stored or used to view the
filtered data with a form, or query, or report.
This parameter selection query should be a pop-up form with several controls
on it. Once parameters have been selected, a command button will begin the
magic.
I can build the query in text form in a text box based on the selections on
the form, but I am not sure how to execute it as a query in Access, but I
guess that is another issue for after I get over this one. I will have
several issues which may require several postings over time, but the first
one I am dealing with today is this:
The sort and filter form may look to the user like this.
1. Priority Level between [_____] and [_____] '// an integer value from
two comboboxes linked to the same table field.
2. Commercial or residential (O) (O) '//choose one of two grouped
option buttons
3. Date Range between [__/__/__] and [__/__/__]
4. (there are more options but lets just use this for now)
In order to test for syntax, I am building the query statement by
concatenating strings to it and displaying it in a text box on the form.
In its simplest form it is:
"SELECT * from [Project List]"
As the user selects the parameters this will grow with a where clause
"SELECT * from [Project List] WHERE .AND..ORDER BY.."
I did this exact same thing on another application for another user using a
pure VB6 form connected to an Access 2000 MDB database. On that
application, all forms were created in Visual Studio as a stand alone
application.
On THIS application, The user already has the database and a few forms
created in Access that would take too much time to reconstruct in Visual
Basic as a whole new program. I am having to work with what I have. But I
am getting bogged down with the basic differences in Access controls and VB
forms and controls:
When I click the command button to display the query with just one parameter
option ( Priority from _x_ to _y_ ),
In my VB from it works just fine. In the Access Form I get an Error Message
#2185 "You can't reference a property or method for a control unless the
control has the focus".
I guess that means that I have cant just write the code in the module, but I
have to cut it up and place into each "gotfocus" event, and I need to
"setfocus" on each control one at a time just get the values to build the
same query. And once I set focus on another control I can no longer
reference the previous control to make a decision or calculation??? Sounds
like a lot of got focus events and maybe copying the values into New
variables created in code on the modular level.
Questions:
1. Is there a better way? Is there an easier way (less coding) to get
around this?
2. Can I create a single POP-Up form in Visual Basic and call it from
another form created in Access, and then using the resulting query, display
on an Access Form or Datasheet view or report? I guess I am talking active
X control but that "sounds" over my level of skill.
3. Know of a "low cost/No cost" add in that already exists out there?
I wuz supposed to be dun. I am under the gun. I ain't havin' no fun.
Sincerely,
StarfishJoe
He has an Access 97 database, (about to be upgraded to Access 2000), that
needs enhancing.
One of the features he wants is a form of text boxes and parameters to sort
and filter on.
The form should build a query that can be stored or used to view the
filtered data with a form, or query, or report.
This parameter selection query should be a pop-up form with several controls
on it. Once parameters have been selected, a command button will begin the
magic.
I can build the query in text form in a text box based on the selections on
the form, but I am not sure how to execute it as a query in Access, but I
guess that is another issue for after I get over this one. I will have
several issues which may require several postings over time, but the first
one I am dealing with today is this:
The sort and filter form may look to the user like this.
1. Priority Level between [_____] and [_____] '// an integer value from
two comboboxes linked to the same table field.
2. Commercial or residential (O) (O) '//choose one of two grouped
option buttons
3. Date Range between [__/__/__] and [__/__/__]
4. (there are more options but lets just use this for now)
In order to test for syntax, I am building the query statement by
concatenating strings to it and displaying it in a text box on the form.
In its simplest form it is:
"SELECT * from [Project List]"
As the user selects the parameters this will grow with a where clause
"SELECT * from [Project List] WHERE .AND..ORDER BY.."
I did this exact same thing on another application for another user using a
pure VB6 form connected to an Access 2000 MDB database. On that
application, all forms were created in Visual Studio as a stand alone
application.
On THIS application, The user already has the database and a few forms
created in Access that would take too much time to reconstruct in Visual
Basic as a whole new program. I am having to work with what I have. But I
am getting bogged down with the basic differences in Access controls and VB
forms and controls:
When I click the command button to display the query with just one parameter
option ( Priority from _x_ to _y_ ),
In my VB from it works just fine. In the Access Form I get an Error Message
#2185 "You can't reference a property or method for a control unless the
control has the focus".
I guess that means that I have cant just write the code in the module, but I
have to cut it up and place into each "gotfocus" event, and I need to
"setfocus" on each control one at a time just get the values to build the
same query. And once I set focus on another control I can no longer
reference the previous control to make a decision or calculation??? Sounds
like a lot of got focus events and maybe copying the values into New
variables created in code on the modular level.
Questions:
1. Is there a better way? Is there an easier way (less coding) to get
around this?
2. Can I create a single POP-Up form in Visual Basic and call it from
another form created in Access, and then using the resulting query, display
on an Access Form or Datasheet view or report? I guess I am talking active
X control but that "sounds" over my level of skill.
3. Know of a "low cost/No cost" add in that already exists out there?
I wuz supposed to be dun. I am under the gun. I ain't havin' no fun.
Sincerely,
StarfishJoe