2-part question

J

Jen

Hello everybody.

I have a question that is kind of a 2-part question. The thing is that I try
to have the user to be able to "globally" choose from a "settings form" if a
checkbox in a new form would be checked or not by default.

First, in an Access form I want a checkbox thar gets it's default value
(checked or not checked) from a table field (Yes/No) that the user can
choose/change from the earlier mentioned "settings form" so that next new
form always has this checkbox either checked or not checked by default.
Maybe there is a better way to do this than by a table containing this?

Secondly, if this checkbox is checked that means print a copy also for a
report opened from the form, and also if the checkbox is checked, write
"COPY" in a label on the second outprint of the report.

How would I do this? I tried making a Yes/No field in my settings table and
then put as default property of the frame the checkbox is in (yes it's in a
frame for clarity) = [egna_uppgifter]![kopia] but then I can't use it. The
checkbox is grayed out when the form is loading and I can check it but then
no more uncheck it.

Jen
 
A

Albert D. Kallal

There is several way to set a default. It depends on how users add new
records.

If you always provide some type of "add new" button, then you simply send
the form to a new record like:

DoCmd.GoToRecord acActiveDataObject, , acNewRec

Me!City = dlookup("City","tblDefaults")

You can also create a custom function, and think that works ok. For example,
I have a screen where you can set the default city, province etc. So, the
default for City field is:

=(GetRidesDefault("DefaultCity"))

The code for GetRidesDefault is a public function, and I simply have a
database table with a field for each type of default (that is ONE record).

I have not tried, but you probably can also use dlookup as a default, and
not even bother with a custom function.

=dlookup("City","tblDefaults")

For the printing of a reprot twice.

You can always make a copy of the report and use that. The code behind the
buttion could be:

docmd.OpenReport "thereport"

If me!CheckBox = True then
docmd.OpenReport "thereportCheck"
endif

On the other hand, if your development team *REALLY* only wants one report,
then you can simply set a public var in your current form with the buttion.

You then go:

bolShowCheck = false
docmd.OpenReport "theReprot"
bolShowCheck = True
docmd.OpenReport "theReport"

In the reprots on-format event (for whatever section), you simply go:

if Forms!yourform.bolShowCheck = True then
textbox.Visiable = true
end else
textboxonreport = false
end if
 
A

Albert D. Kallal

Arrrr. bumped send key...

There is several way to set a default. It depends on how users add new
records.

If you always provide some type of "add new" button, then you simply send
the form to a new record like:

DoCmd.GoToRecord acActiveDataObject, , acNewRec

Me!City = dlookup("City","tblDefaults")

You can also create a custom function, and think that works ok. For example,
I have a screen where you can set the default city, province etc. So, the
default for City field is:

=(GetRidesDefault("DefaultCity"))

The code for GetRidesDefault is a public function, and I simply have a
database table with a field for each type of default (that is ONE record).

I have not tried, but you probably can also use dlookup as a default, and
not even bother with a custom function.

=dlookup("City","tblDefaults")

For the printing of a report twice.

You can always make a copy of the report and use that. The code behind the
button could be:

docmd.OpenReport "thereport"

If me!CheckBox = True then
docmd.OpenReport "thereportCheck"
endif

On the other hand, if your development team *REALLY* only wants one report,
then you can simply set a public var in your current form with the button.

You then go:

bolShowCheck = false
docmd.OpenReport "theReprot"

if me!chkBox = true then
bolShowCheck = True
docmd.OpenReport "theReport"
endif

In the reports on-format event (for whatever section), you simply go:

if Forms!yourform.bolShowCheck = True then
textboxOnReport.Visiable = true
end else
textboxOnReport = false
end if
 

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