Check a check box based on the entry in another field

Confused re: Access

New member
Local time
Yesterday, 23:17
Joined
Jan 30, 2013
Messages
8
I am new to the forum, and to Access 2003 (the version I'm using), and I hope I have put this question in the right place. I'm using a form, but based on my research, I think I need to create a query, so here's my question for the community:

I have a 4-part form divided into tabs. I have a check box called "Additional Parts?" on the first tab (called "Part #1") that I want to check automatically if something is entered in a field called "Qty 2" in the second tab (called "Part #2"). If nothing is entered in "Qty 2," the "Additional Parts?" check box should be unchecked.

How do I make this happen?

Please be aware that I don't know much about Access 2003, so tell me as much as possible about where to go to enter the information. I have found in much of my searching for answers to my many questions, people on the forums tend to expect a certain level of knowledge about the program. Please just figure I have no knowledge and need my hand held throughout. :o

Thanks!
 
In the "After Update" event of your Qty 2 Textbox, you would have to write some VBA that looked something like this:

If IsNull(me!yourtextboxname) then
me.yourcheckboxname = 0
else
me.yourcheckboxname = -1
end if
 
Thank you for the reply, but when I did that, I got this error message:

Microsoft Office Access can't find the macro 'If IsNull(me!Qty 2) then me.'
The macro (or its macro group) doesn't exist, or the macro is new but hasn't been saved.
Note that when you enter the macrogroupname.macroname syntax in an argument, you must specify the name the macro's macro group was last saved under.
--end message--

What do I do now?

FYI, this is the code I entered in the After Update event of the Qty 2 box (which is a number type box):
If IsNull(me!Qty 2) then
me.Additional Parts? = 0
else
me.Additional Parts? = -1
end if
 
Make this change:

If IsNull(me![Qty 2]) then
me.[Additional Parts?] = 0
else
me.[Additional Parts?] = -1
end if

Is Qty 2, the name of the textbox, or the name of the field? In the future, try to avoid having spaces in field names...its a bit of a pain! Its also helpful to name textboxes something like txtQuantity, chkAdditionalParts etc... that way, at a glance, you can identify what you are looking at.
 
I got the same error with that change.

Qty 2 is the name of the field. I'm not sure what a textbox is. Isn't that just a box with text and not necessarily a piece of the table?

I will make a note of no spaces in field names. Thanks!
 
Tables have "fields" and "Records"
Forms have "objects"

In the form, the object is where you enter the data for a "field". The data entered would be the record. If you open your form in design view and open the "properties" tab, click on your textbox where you are entering your Qty 2 data. In the properties section on the right hand side, go to the "Other" tab and look at the "Name" part. This is what your textbox is called.
 
This is the same process to figure out what your checkbox is called aswell
 
It seems I was correct about my names. It also seems I was entering the code in the correct place. Now I'm not sure what to do. I need the "Additional Parts?" object to be checked when someone inputs a quantity in the "Qty 2" object in the form.
 
Try this:

If me![MainFormName]![Qty 2] = "" then
me![MainFormName]![Additional Parts?] = 0
else
me![MainFormName]![Additional Parts?] = -1
end if
 
or this:

If IsNull(me![MainFormName]![Qty 2]) Then
me![MainFormName]![Additional Parts?] = 0
else
me![MainFormName]![Additional Parts?] = -1
end if
 
That didn't work either. Is it possible I need to create a macro? It keeps telling me it can't find the macro.

BTW, thank you so much for continuing to try to help me out with this.
 
Have you coded it EXACTLY like this:

If IsNull(me![MainFormName]![Qty 2]) Then

Me![MainFormName]![Additional Parts?] = 0

Else

Me![MainFormName]![Additional Parts?] = -1

End if

And are positive its in the after update event? Can you copy and paste your exact code for me?
 
Yes, I am positive. Here's the code, entered in the "After Update" in the Events tab of the Qty 2 object (with carriage returns everywhere there's a line break):

If IsNull(me![RMA 2013]![Qty 2]) Then
Me![RMA 2013]![Additional Parts?] = 0
Else
Me![RMA 2013]![Additional Parts?] = -1
End if

When the error message appears, the brackets around RMA 2013 (the form name) disappear. I'm not sure if that means anything or not. It keeps telling me it can't find the macro.
 
it says "Microsoft Office Access can't find the macro 'RMA 2013'
The macro (or its macro group) doesn't exist, or the macro is new but hasn't been saved."?

This is very strange. I wonder if I am missing something as I use Access 2010. I have a feeling that isn't the problem though, as this is some very simple code. Is it possible for you to post your database here?
 
I have no idea how to do that. I'm concerned that I've spent too much time on this as it is, and you have spent plenty of time as well. I think I'll just make it a manual check box and check it myself if I have additional parts.

Thank you for your time and attempts to help.
 

Users who are viewing this thread

Back
Top Bottom