tick a checkbox on another form

murray83

Games Collector
Local time
Today, 23:55
Joined
Mar 31, 2017
Messages
756
so for my current foray i wish to tick a checkbox on one form called Satchel when i press a button on another form

but have hit a snag, and i belive it's an easy fix and im close but cant seem to find it to make it work

here is my current coding

Code:
Private Sub cmdYes_Click()

DoCmd.SetWarnings False 'turns off the warning message about updating lines

Me.cmdNo.Visible = False 'hides no option

Me.txtNoPouch.Visible = False 'hides no option for pouch

Me.txtPouch.Visible = True 'shows keep pouch text

Me.lblGotIt.Visible = True 'shows you go it label

Me.imgOcarina.Visible = True 'shows image of item got

Me.Form.Satchel.checkOcarina.Value = True

DoCmd.RunSQL ("Update tbl_Items set [Held] = 1 WHERE [Item] = 'Jade Ocarina' ") 'adds the Ocarina to your items held

End Sub

have tried google and searching here and even looking here http://access.mvps.org/access/forms/frm0031.htm but to no avail :banghead::banghead:

please help

cheers
 
Last edited:
but have hit a snag
and the snag is??
EDIT - I see a problem with the Me.Form line but is there a connection between the sql and the checkbox you're trying to set? And is the form in question a sub form?
 
Last edited by a moderator:
better check my post again - it was edited & has questions
Form reference is wrong but cannot advise explicitly without knowing if it's a subform
There are at least 3 examples I could provide but don't know which is applicable
 
nope not a subform and the sql has nothing to do with the check box on the Satchel form being ticked
 
Hi. Not sure if this is what you're asking but let's say there are two forms: Form1 and Form2. From Form1, to check a box on Form2, first, both forms have to be open at the same time. Then, to check the box, you can try the following code from Form1.
Code:
Forms!Form2.CheckboxName=True
Hopefully, you can apply this principle to your actual setup. Cheers!
 
OK. probably seemed like a lot of unnecessary q's but if the sql was setting a field value that the check was based on, setting value of control would likely be a mistake. I guess other form is named Satchel then. Turning off warnings is risky. In fact, you left them off in your example. Forgot to inquire if target form is open (sorry) - see notes. An error handler is advisable when running action sql or query. Consider
Code:
Private Sub cmdYes_Click()
 On Error GoTo errHandler

With Me
 .cmdNo.Visible = False 'hides no option
 .txtNoPouch.Visible = False 'hides no option for pouch
 .txtPouch.Visible = True 'shows keep pouch text
 .lblGotIt.Visible = True 'shows you go it label
 .imgOcarina.Visible = True 'shows image of item got
End With

Forms!Satchel.checkOcarina = True
'syntax for other non-subform is
'Forms!frmName.ControlName PROVIDED form is open
 
'add the Ocarina to your items held
CurrentDb.Execute "Update tbl_Items set [Held] = 1 WHERE [Item] = 'Jade Ocarina' ", dbFailOnError

exitHere:
'reset controls if error?
Exit Sub

errHandler:
msgbox "Error " & err.number & ": " & err.description
resume exitHere

End Sub
 
Last edited by a moderator:
Hi. Good luck with your project.

thanks, i know i have said solved but last one for tonight and this thread

how the dickens do i get my dam picture to appear i have looked here for order of events for a form
https://support.office.com/en-gb/article/order-of-events-for-database-objects-e76fbbfe-6180-4a52-8787-ce86553682f9#bm3

and this is my code, which in my head should be bloody working ( sorry for the outburst )

Code:
If Me.checkOcarina = True Then
Me.lblOcarina.Visible = True
Me.imgOcarina.Visible = True
Else
Me.lblOcarina.Visible = False
Me.imgOcarina.Visible = False
End If

i have tried this in, on open, on load, on current, on activate and lastly on resize but nope, not fliping working ;(
 
thanks, i know i have said solved but last one for tonight and this thread

how the dickens do i get my dam picture to appear i have looked here for order of events for a form
https://support.office.com/en-gb/ar...ects-e76fbbfe-6180-4a52-8787-ce86553682f9#bm3

and this is my code, which in my head should be bloody working ( sorry for the outburst )

Code:
If Me.checkOcarina = True Then
Me.lblOcarina.Visible = True
Me.imgOcarina.Visible = True
Else
Me.lblOcarina.Visible = False
Me.imgOcarina.Visible = False
End If
i have tried this in, on open, on load, on current, on activate and lastly on resize but nope, not fliping working ;(
Hi. Sorry but your last question is "out of context" (to me anyway) since we can't see what you're looking at. Please remember we are not familiar with your database, so you may have to explain what's happening a little more for us to understand the problem. Are you asking how to make a control visible if the checkbox is checked? If so, you should be able to use something like:
Code:
Me.PictureControlName.Visible = Me.CheckboxName
As for which event to use, it would depend on how or when the checkbox gets checked. If you want this code to take effect as you navigate from one record to another, you should use the Form's Current event. If the checkbox gets checked manually, then you could use the Checkbox's AfterUpdate event.
 
imgOcarina is an image control? When you put control on form you set its picture property? Are you trying to change the image in it based on a record or some other operation?
It may be visible (but not obvious because there's no image). Make sure it has a border or some property that makes it obvious if there's no pic.
 
imgOcarina is an image control? When you put control on form you set its picture property? Are you trying to change the image in it based on a record or some other operation?
It may be visible (but not obvious because there's no image). Make sure it has a border or some property that makes it obvious if there's no pic.

no not trying to change the image just wanting it to be visible as default its hidden from view so people wont see what they need to collect
 
what about
When you put control on form you set its picture property?
If not - there's nothing to show, hence can appear invisible
 
what about If not - there's nothing to show, hence can appear invisible

see attached images from design view of the form
 

Attachments

  • imgOc.jpg
    imgOc.jpg
    98.2 KB · Views: 46
  • lblOc.jpg
    lblOc.jpg
    71.8 KB · Views: 46
Why not put a MSGBOX in each path and see what is produced.?
The code might not be running at all.?
 

Attachments

Last edited:
I don't get it. How to replicate your issue??

ok so when you have clicked examine table and then clicked yes

it opens up the satchel form and ticks the check box

once this check-box on satchel is ticked i would like/want the picture & label of the item to appear, and on the inverse when its not ticked blank as a clear blue sky ( nothing showing )
 

Users who are viewing this thread

Back
Top Bottom