changing control source for controls at runtime

S

SUZYQ

I have an unbound form that I use for data entry. However, the users
like to see what records they have entered each day, so they need the
ability to scroll through the records.

I added a command button to the form that switches the form between
being unbound for data entry, and being bound for record perusal. I
have no problem setting the form's record source to a SQL statement.

What I'm having trouble with is setting the unbound controls to have a
bound control source.

I've defined a recordset to be the same as the form's record source. I
was then setting each control to the corresponding field in the
recordset.

eg: Me.txtRecdDt.ControlSource = "=rsMain!RecdDt"

This isn't working.

There must be something I'm missing.

Thanks,
 
A

Avlan

Isnt it Me!txtRecdDt.ControlSource = "=rsMain!RecdDt" ?

As in, with the exclamation mark? Not sure but I know it sometimes
makes a difference.
 
A

Avlan

Can't you use the 'RowSource' of the form to achieve what you want? If
thats possible, I know you can set the RowSource of f.i. a dropdown-box
very easily with smt like

DropDownName.RowSource = "SELECT 'records' FROM 'tblMain' WHERE 'date'
= '21-7'"

That way a dropdown will remain unbound (always better) and you have
the code neatly in your form's module
 
S

SUZYQ

OK, so I found my problem. I was opening the form in data entry mode
(Property Data Entry = Yes) so I wasn't seeing the records.

Also, the syntax was to set the recordsource of the form, then each
controlsource was set like:

Me.txtRecdDt.ControlSource = "=RecdDt"

I didn't need to bring a recordset into the mix.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top