Re: Checkbox



okay, since each printer is specific to an employee (sits on a specific
employee's desk), then presumably you have a one-to-many (or one-to-one)
relationship set up between tblEmployees and tblPrinters - with the primary
key from tblEmployees used as a foreign key in tblPrinters. in this case, i
would probably *not* include a "printer, Yes/No" field in tblEmployees.

it's not clear whether you're using the form strictly for "looking" at
records, or for data entry also. assuming the form is used for data entry
and records review, and assuming that the form is based on tblEmployees, and
the subform is based on tblPrinters - with the appropriate LinkChildFields
and LinkMasterFields settings in the subform control, i might do the
following:

in the mainform's Current event, put the following code

If Me!PrinterSerial.Form.Recordset.Recordcount > 0 Then
Me!PrinterSerial.Visible = True
Me!printchk = True
Else
Me!PrinterSerial.Visible = False
Me!printchk = False
End If

assuming that you want to be able to add printer information for a specific
employee, i'd also add the following code to the (unbound) checkbox's
AfterUpdate event, as

Me!PrinterSerial.Visible = Nz(Me!printchk = True, False)

note that, if an employee record has a related printer record, unchecking
the checkbox in the form will *not* delete the printer record - it will only
hide the printer subform.

hth


"Chip1035" <Chip1035@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A0CACB28-E490-4D97-BEB2-B8F6C658871A@xxxxxxxxxxxxxxxx
> I have three tables, one table is employees with their extension, another
> table with computer system configuration (serial #, OS, Office) another
table
> has the printers (serial #, make/model, ink). I have put together a form
> that puts all three in one view. Form goes like this:
> Employee Name and their extension, computer serial number of their
computer
> with a command button to open the computer form showing all the
information,
> and finally printer serial number with a command button opening the
printer
> form, showing all the information.
>
> What I want to do is have a checkbox for the printer. If an employee has
a
> printer on their desk, I want to place a checkmark in the checkbox and
have
> the printer serial number show up. If the employee does NOT have a
printer,
> I want the checkbox unchecked and the printer serial number text box to be
> hidden.
>
> Right now, what it is doing is, if I place a checkmark for an employee who
> has a printer, save the record, go to an employee record who does NOT have
a
> printer, the checkbox is checked and the printer serial number is visible
but
> blank. If I place a check in the checkbox, the printer serial number is
> visible, it stays checked for all records with the printer serial visible,
if
> I uncheck, printer serial number hides, all records are unchecked with
> printer serial # hidden.
>
> "tina" wrote:
>
> > > Record three has no printer, therefore, should
> > > not have a checkmark and printer visable.
> >
> > maybe i have misunderstood what you're doing here. the code does nothing
to
> > add or delete a checkmark in the table's Yes/No field - it only acts to
on
> > what is there. you (or somebody) has to enter or remove a checkmark from
> > each record, according to whether or not there is a printer associated
with
> > the record.
> >
> > the code in the form's OnCurrent event shows or hides the subform (i am
> > assuming that PrinterSerial is the name of the subform control) in the
> > current record based on whether or not there is a checkmark in the
Yes/No
> > field for that record. the same code in the checkbox control's
AfterUpdate
> > event shows or hides the subform based on the new value entered in the
> > Yes/No field.
> >
> > > Should there be a "IF" statement/code?
> >
> > Me!PrinterSerial.Visible = Nz(Me!printchk = True, False)
> >
> > works exactly the same as
> >
> > If Nz(Me!printchk = True, False) = True Then
> > Me!PrinterSerial.Visible = True
> > Else
> > Me!PrinterSerial.Visible = False
> > End If
> >
> > use either one, to suit yourself.
> >
> > if you're doing something different than what i understood from your
posts,
> > please post a more detailed explanation of the table(s), the
form/subform,
> > and what you're trying to accomplish.
> >
> > hth
> >
> >
> > "Chip1035" <Chip1035@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > news:D2CA3AF1-6FB3-4B7C-AEB2-2A22227E812E@xxxxxxxxxxxxxxxx
> > > I want to thank you for your help... I really appreciate it!
Although,
> > it
> > > still is not working...
> > >
> > > The error has gone away, but the oriniginal problem persists. Record
one
> > > has no printer, no checkmark, no printer visable. Record two has a
> > printer,
> > > place a checkmark, printer is visable. Here is the problem... When I
go
> > back
> > > to record one or go to record three, checkmark is present and printer
is
> > > visable, when it should not. Record three has no printer, therefore,
> > should
> > > not have a checkmark and printer visable.
> > >
> > > Should there be a "IF" statement/code?
> > >
> > > "tina" wrote:
> > >
> > > > try
> > > >
> > > > Me!PrinterSerial.Visible = Nz(Me!printchk = True, False)
> > > >
> > > > hth
> > > >
> > > >
> > > > "Chip1035" <Chip1035@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > > > news:41FA1C46-A6AB-4064-BB9A-6AA240DF1E2D@xxxxxxxxxxxxxxxx
> > > > > Found it... Now, when I access the form, I get an error:
> > > > >
> > > > > Run-Time error '94'"
> > > > > Invalid use of Null
> > > > >
> > > > > Click on Debug and it brings me to the Form_Current line with the
code
> > > > > highlighted. Here is my code
> > > > >
> > > > > PrinterSerial.Visible = Me!printchk = -1
> > > > > ^---Is the name of textbox ^---Is the name of the checkbox
> > > > > I want visable if checkbox is
> > > > > checked, not if check box is
> > > > > not checked
> > > > >
> > > > > If I click on End, tehn go fourth with checking the checkbox, no
error
> > > > comes
> > > > > up but still does what I explained earlier.
> > > > > "tina" wrote:
> > > > >
> > > > > > in design view, when you open the Properties box, make sure the
> > > > Properties
> > > > > > box's title bar says Form - not Section, or anything else. if it
> > doesn't
> > > > say
> > > > > > Form, then double click in the gray square in the upper left
corner
> > of
> > > > the
> > > > > > design view window, at the junction of the vertical and
horizontal
> > > > rulers;
> > > > > > that should change the Properties box title bar to Form. then
click
> > the
> > > > > > Events tab and proceed as stated in my previous post.
> > > > > >
> > > > > > hth
> > > > > >
> > > > > >
> > > > > > "Chip1035" <Chip1035@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > > > > > news:AFE74F0D-EDA2-4528-8CB1-3030C541CF50@xxxxxxxxxxxxxxxx
> > > > > > > I cannot locate OnCurrent event procedure. I am using Access
> > 2000, am
> > > > I
> > > > > > > missing something, I feel like this is suppose to be right in
> > front of
> > > > me.
> > > > > > > I right click on the an emtpy area in Design View, select
> > Properties,
> > > > > > cannot
> > > > > > > see a OnCurrent.
> > > > > > >
> > > > > > > "tina" wrote:
> > > > > > >
> > > > > > > > in the table underlying the form, you should have a field to
> > store
> > > > the
> > > > > > > > Yes/No value re printer availability. make sure that field
is
> > > > included
> > > > > > in
> > > > > > > > the form's RecordSource. bind the checkbox control to the
Yes/No
> > > > field
> > > > > > (set
> > > > > > > > the checkbox control's ControlSource to the name of the
field).
> > then
> > > > > > include
> > > > > > > > your code in the form's OnCurrent event procedure, and in
the
> > > > checkbox
> > > > > > > > control's AfterUpdate event procedure. to add the code:
> > > > > > > >
> > > > > > > > 1. open the form in design view.
> > > > > > > > 2. open the Properties box (if it's not already open), click
on
> > the
> > > > > > Events
> > > > > > > > tab, and then double click in the white space at the right
of
> > the On
> > > > > > Current
> > > > > > > > event (first event listed). Access will create the event
> > procedure
> > > > and
> > > > > > open
> > > > > > > > the VBA Editor window, with the cursor inside the procedure.
> > > > > > > > 3. enter your line of code, as
> > > > > > > >
> > > > > > > > Private Sub Form_Current()
> > > > > > > >
> > > > > > > > PrinterControl.Visible = (Me!CheckBoxName = -1)
> > > > > > > >
> > > > > > > > End Sub
> > > > > > > >
> > > > > > > > 4. go back to form design view.
> > > > > > > > 5. click on the checkbox control to select it.
> > > > > > > > 6. in the Properties box, again double click on the
AfterUpdate
> > > > event
> > > > > > line.
> > > > > > > > 7. enter your code inside the procedure, same as before.
> > > > > > > >
> > > > > > > > hth
> > > > > > > >
> > > > > > > >
> > > > > > > > "Chip1035" <Chip1035@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
> > > > > > > > news:0594D03D-2A50-43DD-971F-85BF54CB86C5@xxxxxxxxxxxxxxxx
> > > > > > > > > This is what I got
> > > > > > > > > Inventory Form which shows employee name, extension,
computer
> > > > serial
> > > > > > > > number
> > > > > > > > > and a checkbox for printer. When the checkbox is checked,
a
> > > > subform
> > > > > > shows
> > > > > > > > > the printer's serial number.
> > > > > > > > >
> > > > > > > > > I have the following code as an AfterUpdate event
> > > > > > > > > PrinterControl].Visible = Me![CheckBoxName] = -1
> > > > > > > > >
> > > > > > > > > Now, when I view a record and the checkbox is empty, the
next
> > > > record
> > > > > > has
> > > > > > > > the
> > > > > > > > > checkbox empty, but if I want to place a checkbox to show
that
> > > > > > employee
> > > > > > > > has a
> > > > > > > > > printer, the previous record has the checkbox checked with
the
> > > > printer
> > > > > > > > > subform empty. If I uncheck the record and go back to the
one
> > > > that
> > > > > > should
> > > > > > > > be
> > > > > > > > > checked, I find the checkbox unchecked.
> > > > > > > > >
> > > > > > > > > It was suggested I enter the code above in the Form's
current
> > > > event.
> > > > > > How
> > > > > > > > > can I access the Form's current event, in order to place
the
> > code
> > > > > > there?
> > > > > > > > If
> > > > > > > > > needed... If there is another code all together, bring it
on
> > so I
> > > > > > could
> > > > > > > > try
> > > > > > > > > it. NOTE: I am not a pro at Access, rather just a
> > beginner...
> > > > Thank
> > > > > > you
> > > > > > > > > for any and all help, in advance...
> > > > > > > > > --
> > > > > > > > > -Chip
> > > > > > > > > =)
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > >
> > > >
> > > >
> >
> >
> >


.