Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox to populate field with data. 'how to' 1

Status
Not open for further replies.

Judalie

Programmer
Mar 25, 2002
40
0
0
US
I need to know how to get the field in a subform populated with data from form when checkbox is checked...

inputform has a field adoptnum
subform is list of possible animals to adopt
when checking the box in record of specific animal, have the adoptnum field
automatically populate with adoptnum from inputform..

can someone help me with this.. i need to know where to put the formula
and how to word the statement...please?
thanks much!
j
 
Assuming your checkbox field is named chkSelectYn, use its AfterUpdate event (in the subform) to copy the adoptnum value from the "inputform" (Parent) to the subform (Child). For example,
Code:
Private Sub chkSelectYn_AfterUpdate()
  If Me!chkSelectYn = True Then
    Me!adoptnum = Parent!adoptnum
  Else
    Me!adoptnum = 0  'or whatever # is appropriate
  End If
End Sub
 
I knew the HOW but not the HOWTO so I didn't respond. I was missing the Parent! call. I kept getting stuck on trying to reference the subform and the main form (controls having the same name).

Good job. Star.

Thanks. Sean.
 
I am getting an error runtime 424, object required.
what do you think i'm doing wrong..j
 
I've read the help on error 424... still cannot figure out what's missing..

i created a field for the checkbox on the table and added it to the query used for the form..thought that might be the problem but still isn't working..
 
What if the form that I called subform isn't really a subform but in fact another form that opens within the input form..there is an 'adopt' button that opens the form that is listing of animals that are still available...adopter number = 0....

is that why it doesn't recognize the adopters!AdopterNumber as an object?
 
Is there a way to refer to a field of current record being displayed..from another open form..

does this make sense?
 
Change the field name qualification from Parent!adoptnum to Forms!frmMyInputForm!adoptnum, where "frmMyInputForm" is the name of the other open form.
 
Oh WONDERFUL!!!! it works
thanks so very much!!!!!
forever grateful
j
 
I am now having a problem that don't know how to fix... i want the checkbox
to always be clear when form opens...how can i get that to happen..

i wondered if there is a way to put a statment in the open form procedure section and i tried that and it doesn't work...

i tried the before update..which didn't work..and the getfocus and enter which works of course only when focused or entered...help!

j
 
You could set them false almost at any time, but what do you need the result for? When you select the checkbox, and it populates the other adoptnum field, what do you need it for after that?

It sounds like it should be a Adopted? checkbox. You check this from the available animals for adoption right? So if you check this then the animal is being adopted?

If that is the case, the query for your form could have a False criteria on that field, so that the animals which have been checked (meaning adopted) do not show up again.

Does this sound like the process your are undertaking?

Sean.
 
Sean, yes you do have the right idea....and maybe I'm using the wrong tool....

i have a form called adopter...then open another form adopthorse which shows only the animals that are not adopted...i'm using the checkbox to have that form automatically populate the adopternumber field in the adopthorse form so that they don't have to type in the number, chancing typo, etc...
then
there is a subform on the adopter form that lists the animals that person adopted...giving other field, fee, fee code, etc.. that subform also has a checkbox
in case the adopter changes mind and doesn't want that animal...checkbox puts null values in the necessary fields, including a 0 in the adopternumber field..this process puts the animal back in the adopthorse form so can be adopted next time.
what is happening to me, once i adopt, then unadopt, the checkbox is marked already in the adopthorse form...but it doesn't activate the process of adopting unless i uncheck it and recheck it.. i just want all of the checkboxes to be clear when each form is opened.. should i be using a command button instead? thanks so much for your help and i hope i'm not confusing you.j
 
You are missing the step of clearing the checkbox on the adopthorse form, when you clear the check on adopter form. Post the code behind the clearing or unadopting of an animal.

Also, if you only open the adopthorse for to issue a horse to someone, then you would place:

me.txtAdopter = Forms!MyInputForm.Adopter

This way, just by opening the other form, you are linked to the adopter, not only when you use the checkbox.

Sean.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top