Checkbox to display new

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a main form: frmInvest
and a subform: subfrmTx
The subform is invisible until a checkbox (chkSub) on my main form is
checked.

I would like to add code to the checkbox (chkSub) that not only makes the
subform visible when checked, but also positions the cursor into the subform
on a blank, new record so that users only have the option to add a new,
single record into the subform.

TIA
Janna
 
Janna said:
I have a main form: frmInvest
and a subform: subfrmTx
The subform is invisible until a checkbox (chkSub) on my main form is
checked.

I would like to add code to the checkbox (chkSub) that not only makes
the subform visible when checked, but also positions the cursor into
the subform on a blank, new record so that users only have the option
to add a new, single record into the subform.

Normally, you'd set the subform to "Data entry" on the Data tab of the
property sheet, to only have the possibility of new records. That doesn't
allow you to see old records. To see old records, you need to set the Allow
Edits property to False and use some code like this to get where you want:

Me.SubformName.Visible = True
DoCmd.GoToControl ("SubformName")
DoCmd.GoToRecord , , acNewRec
 
I'm having a similar problem with a checkbox control - When the checkbox is
CHECKED, that is "Yes", I want to display other hidden fields. The code I'm
using is similar to the following:
if [checkbox] = "Yes" then
me.fieldname.visible = true
else
me.fieldname.visible = false
endif

Can you help?@
 
A checked check box is equal to True, not to "Yes".

Try:

Me.Fieldname.Visible = Me.checkbox

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


TechnoNurse said:
I'm having a similar problem with a checkbox control - When the checkbox
is
CHECKED, that is "Yes", I want to display other hidden fields. The code
I'm
using is similar to the following:
if [checkbox] = "Yes" then
me.fieldname.visible = true
else
me.fieldname.visible = false
endif

Can you help?@



Arvin Meyer said:
Normally, you'd set the subform to "Data entry" on the Data tab of the
property sheet, to only have the possibility of new records. That doesn't
allow you to see old records. To see old records, you need to set the
Allow
Edits property to False and use some code like this to get where you
want:

Me.SubformName.Visible = True
DoCmd.GoToControl ("SubformName")
DoCmd.GoToRecord , , acNewRec
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
Make that:

Me.Fieldname.Visible = Me.checkbox.Value

Since there is a bug in the checkbox in some Access versions that will keep
Access from closing without explicit reference to the Value property, or the
actual value.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Douglas J. Steele said:
A checked check box is equal to True, not to "Yes".

Try:

Me.Fieldname.Visible = Me.checkbox

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


TechnoNurse said:
I'm having a similar problem with a checkbox control - When the checkbox
is
CHECKED, that is "Yes", I want to display other hidden fields. The code
I'm
using is similar to the following:
if [checkbox] = "Yes" then
me.fieldname.visible = true
else
me.fieldname.visible = false
endif

Can you help?@



Arvin Meyer said:
Janna wrote:
I have a main form: frmInvest
and a subform: subfrmTx
The subform is invisible until a checkbox (chkSub) on my main form is
checked.

I would like to add code to the checkbox (chkSub) that not only makes
the subform visible when checked, but also positions the cursor into
the subform on a blank, new record so that users only have the option
to add a new, single record into the subform.

Normally, you'd set the subform to "Data entry" on the Data tab of the
property sheet, to only have the possibility of new records. That
doesn't
allow you to see old records. To see old records, you need to set the
Allow
Edits property to False and use some code like this to get where you
want:

Me.SubformName.Visible = True
DoCmd.GoToControl ("SubformName")
DoCmd.GoToRecord , , acNewRec
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
Back
Top