A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Forms and checkboxes



 
 
Thread Tools Display Modes
  #11  
Old May 25th, 2007, 01:00 PM posted to microsoft.public.access
Amateur
external usenet poster
 
Posts: 337
Default Forms and checkboxes

Dear Wayne,
I tried your code and as well like underneath with ....open = 0
What am I doing wrong, my checkbox always is never checking automatically.

My code:
If (Forms!billsopenvalue!open = 0) Then
Me.paidbillshelp.SetFocus
Forms!billsopenvalue!paidbillshelp.Form!paid = -1
End If

Thanks
Klaus

"Wayne-I-M" wrote:

Steve is right

you have written the code wrong. It should be


Forms!billsopenvalue!paidbillshelp.Form!NameOfBoxO nSubForm = -1


"NameOfBoxOnSubForm" needs changing to what it is

You place this code on the AfterUpdate of the control called "open" on the
main form. Delete all code from the subform check box. The control source
of this check box is the field in the table where you want to store the data
(0 or -1)





--
Wayne
Manchester, England.



"Amateur" wrote:

Dear Wayne I've tried your code in the afterUpdate in in the sub-form as well
as in the main form.
Both trials are not bringing any result. I have the following code
If (Forms!billsopenvalue!open 0) Then
Me.paidbillshelp.SetFocus
Forms!billsopenvalue!paidbillshelp.Form!open = -1
End If

Do you have another solution?
Klaus

"Wayne-I-M" wrote:

Private Sub open_AfterUpdate()
If (Forms!MainFormName!open 0) Then
Me.SubFormName.SetFocus
Forms!MainFormName!SubFormName.Form!BoxOnSubFormNa me = -1
End If
End Sub



Change -
MainFormName
SubFormName
BoxOnSubFormName
to what they really are.

Note I have used Set Focus to enable to value to be set in the subform so
leave that there.

Hope this helps

--
Wayne
Manchester, England.



"Amateur" wrote:

Hi Wayne
The main form field "open" is a result field from a query. If this field has
a positiv value the checkbox on the subform should be unchecked. If the main
form field "open" is showing the value "0" , the checkbox should be checked.
So, to use your explanation:
-1 = Checked
0 = Checked
+1 = not checked
Maybe this explanation helps a bid.
Thanks
Klaus

"Wayne-I-M" wrote:

For text boxes

-1 = Checked
0 = Not checked

So if you put 0 in the main form box you will have a non-checked box on the
sub form.

Sorry but I assume that you are entering either -1 or 0 is this
correct. If not a little more info would be helpfull. You could use an
AfterUpdate event on the box on the main form to set the value of the box on
the sub form or other action but not sure what you're trying to do.






--
Wayne
Manchester, England.



"Amateur" wrote:

I set the Control source property of the box to the following:

=Forms!billsopenvalue!open

But it’s not automatically checked if the value in the field is “0”
Do you have any other idea?
Thanks
Klaus


"Wayne-I-M" wrote:

Hi

Set the source of the box on the sub form to

=Forms!MainFormName!BoxOnMainFormName



--
Wayne
Manchester, England.



"Amateur" wrote:

I have a form with one subform.
I would like that, if on the main form the field “open” has the value “0”
the checkbox on the subform gets automatically checked.
Is that possible and if, how?
Thanks
Klaus

  #12  
Old May 25th, 2007, 01:06 PM posted to microsoft.public.access
BruceM[_2_]
external usenet poster
 
Posts: 1,763
Default Forms and checkboxes

Also, note that SubFormName in the code I suggested is the name of the
subform control. It may not have the same name as the subform. In form
design view (main form), click the subform once to select it, then click
View Properties to verify the name (the top of the property sheet should
say Subform/Subreport). The SetFocus line needs to reference the subform
control.

"BruceM" wrote in message
...
Note that the code is for open, which in this context is the name of the
control bound to the [Open] field. The field and the text box should have
different names so that both you and Access are less likely to be
confused. If the field is named [Open], try something like txtOpen as the
text box name. Another point is that Open is a reserved word in Jet (the
database engine underlying the user interface of the Access programs you
create). The use of reserved words for field and control names should be
avoided. However, if they are used they should be in square brackets. If
you use txtOpen as the name of the text box bound to the [Open] field,
then the After Update event for the *text box* would look something like
this:

Private Sub txtOpen_AfterUpdate()
If Me.[Open] 0 Then
Me.SubFormName.SetFocus
Forms!BillsOpenValue!PaidBillsHelp.Form![txtOpen] = -1
End If
End Sub

The code should work in the form's After Update event as well, and several
other places such as the subform control's Enter event. Note that when
referencing a control (or property) on the active form, you don't need to
use the Forms!etc. syntax. That is to say, your main form's record source
includes the field Open, and txtOpen is on the main form, so you can use
the Me.txtOpen syntax. The long syntax should work, but it is not
necessary. The subform is a separate object, so you need the longer syntax
when referencing it from another form (the main form).

"Amateur" wrote in message
news
Dear Wayne I've tried your code in the afterUpdate in in the sub-form as
well
as in the main form.
Both trials are not bringing any result. I have the following code
If (Forms!billsopenvalue!open 0) Then
Me.paidbillshelp.SetFocus
Forms!billsopenvalue!paidbillshelp.Form!open = -1
End If

Do you have another solution?
Klaus

"Wayne-I-M" wrote:

Private Sub open_AfterUpdate()
If (Forms!MainFormName!open 0) Then
Me.SubFormName.SetFocus
Forms!MainFormName!SubFormName.Form!BoxOnSubFormNa me = -1
End If
End Sub



Change -
MainFormName
SubFormName
BoxOnSubFormName
to what they really are.

Note I have used Set Focus to enable to value to be set in the subform
so
leave that there.

Hope this helps

--
Wayne
Manchester, England.



"Amateur" wrote:

Hi Wayne
The main form field "open" is a result field from a query. If this
field has
a positiv value the checkbox on the subform should be unchecked. If
the main
form field "open" is showing the value "0" , the checkbox should be
checked.
So, to use your explanation:
-1 = Checked
0 = Checked
+1 = not checked
Maybe this explanation helps a bid.
Thanks
Klaus

"Wayne-I-M" wrote:

For text boxes

-1 = Checked
0 = Not checked

So if you put 0 in the main form box you will have a non-checked box
on the
sub form.

Sorry but I assume that you are entering either -1 or 0 is this
correct. If not a little more info would be helpfull. You could
use an
AfterUpdate event on the box on the main form to set the value of
the box on
the sub form or other action but not sure what you're trying to do.






--
Wayne
Manchester, England.



"Amateur" wrote:

I set the Control source property of the box to the following:

=Forms!billsopenvalue!open

But it's not automatically checked if the value in the field is
"0"
Do you have any other idea?
Thanks
Klaus


"Wayne-I-M" wrote:

Hi

Set the source of the box on the sub form to

=Forms!MainFormName!BoxOnMainFormName



--
Wayne
Manchester, England.



"Amateur" wrote:

I have a form with one subform.
I would like that, if on the main form the field "open" has
the value "0"
the checkbox on the subform gets automatically checked.
Is that possible and if, how?
Thanks
Klaus





  #13  
Old May 25th, 2007, 02:00 PM posted to microsoft.public.access
Wayne-I-M
external usenet poster
 
Posts: 3,674
Default Forms and checkboxes

Following on from Bruce's post.

If you can give the names of the forms and the controls then it would be
helpfull.

It should be a very simple operation but it seems that some of the
references in the code may be wrong (names)


--
Wayne
Manchester, England.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:59 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.