is this possible? reload a form that is based on a query with new query that is defined in the form.

  • Thread starter Thread starter mgworek
  • Start date Start date
M

mgworek

I have a basic form.

The form is based on a query, so when I open the form, a pop comes up
where I enter in what I want to query.

So instead of 30,0000 records, I get 1-10 records.

on the form, I have a text box. I want to be able to enter in what I
want to query next and afterupdate have the recordset/form reload with
that query instead of my original qeury.

I figure this has to be done with VB. I am just starting to learn some
VB but I am lost.

Any info would be great, thank you.
 
It does.
You need to apply the new query or table name, or the sql string to
the forms recordsource, then requery the form. Basically
in the even that needs to cause the change (usualy the AfterUpdate of
a control or the Click of a button)..

Me.RecordSource = "[table/query/sql]"
Me.Requery

Or you can look into using the form filter instead. The filter though
needs to be based on an underlying query or table. If the query or
table itself needs to change then use the former method.
 
thank you for the reply. If I changed the RecordSource would i just
put Me.RecordSource = "[SELECT whatever FROM whatever WHERE whatever
= whatever.TEXT]" ?
 
Without the [ ] and the .TEXT property will depend on wether or not
the change is made before the control is updated and what the datatype
is. For a string value after the control is updated it would be

Me.RecordSource = "SELECT whatever FROM whatever WHERE whatever
= '" & formcontrol & "';"

formcontrol.Value can be used as well.
 
Back
Top