Open a form, using a sql string.

  • Thread starter Thread starter g m via AccessMonster.com
  • Start date Start date
G

g m via AccessMonster.com

I need to have an efficient way of reporting any one of (36) fields in a
table.

I have a table called mailingList which has fields Title, Prod_ref, Date ...

I have created a look-up table called attributes

has the following fields :- current_selection
which has values like - Title, Prod_ref, Date...

and view_item. (for the drop-down list)
which has entries like - Customer Title, Product Reference, Order Date.....

With the attribute selected, I then want to open another form, and return
appropriate records. I am quite new to VB, but I think it should be a
docmd.openform, but I cannot get the sql string to work.

In essence, the sql will be something like -

select [current_selection from mailinglist.

I am struggling with the syntax.

Any ideas?

Regards

Gordon.
 
if i understand you correctly: you have a table with 36 fields. you want to
be able to select any one of those 36 fields to display in a form, at
runtime.

you could create a SQL string and assign it to the form's RecordSource every
time you open the form, but you'd also have to set the control's
ControlSource to the appropriate field name. seems like the easiest thing is
to include all the table fields in the form's RecordSource. then, the only
issue is changing the ControlSource of the control on the form, to the name
of the table field you want to display.

you might try using the OpenArgs argument of the DoCmd.OpenForm method, to
supply the name of the field selected from the droplist. put code in the
second form's Load event, to set the control's ControlSource to Me.OpenArgs.
if it doesn't work in the Load event, try running it in the form's Open
event.

hth
 
Thanks alot, I will give that a try, and let you know the result.

Regards,

Gordon
 
Back
Top