Re: Open a form, using a sql string.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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


"g m via AccessMonster.com" <forum@xxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:1c506c0a25394be88da6e2442af81764@xxxxxxxxxxxxxxxxxxxx
> 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.
>
> --
> Message posted via http://www.accessmonster.com


.



Relevant Pages

  • The control is read-only - why?
    ... I created a grid, the recordsource of which is a table. ... The grid does display the data of ...
    (microsoft.public.fox.programmer.exchange)
  • RE: how do i create a combo box?
    ... > The index, beginning with 1, of the column to be stored in the ControlSource ... > fields, and that you'd like to display them in "LastName, FirstName" format, ... > Finally, to display any of the other columns in a separate textbox, use the ... >> be able to select the first and last name for an employee, ...
    (microsoft.public.access.forms)
  • RE: how do i create a combo box?
    ... > The index, beginning with 1, of the column to be stored in the ControlSource ... > fields, and that you'd like to display them in "LastName, FirstName" format, ... >> is based on fields from one table that lists the employees names. ... >> be able to select the first and last name for an employee, ...
    (microsoft.public.access.forms)
  • RE: Show controls when value is selected in combo box
    ... the form's RecordSource property into which data entered into the control is ... Are these hidden controls on a subform or the main form? ... post the ControlSource, RowSource, and BoundColumn properties, and the. ... >>> tblDisbursement is the record source for the hidden combo box. ...
    (microsoft.public.access.forms)
  • Re: Using SQL inside a Form
    ... thanks- I am using it as a source for the combobox - the problem is ... LOAD event that you want or the CURRENT event as you move from record to ... controlsource of the dropdown control a string that extracts from table ...
    (microsoft.public.access.formscoding)