• Status: Solved
  • Priority: High
  • Security: Public
  • Views: 69
  • Last Modified:

place a checkbox on subform and use a field in linked sql server table

Access 2010
sql server 2008
Access form and subform

I need to place a checkbox on a subform and use a linked sql server table  and control source the checkbox to the field in sql server ?

What field (datatype) do i use on the sql server side ?
and any others issues that nay arise, what might they be ?

Thanks
fordraiders
0
Fordraiders
Asked:
Fordraiders
  • 12
  • 10
1 Solution
 
PatHartmanCommented:
I would use SmallInt.  Access supports three states for Yes/No data types - Null, true, false but SQL server only allows two for bit data types which is the obvious conversion path.  If your Y/N fields always have a default and are never null, then bit will be fine.  If they don't have a default and there may be some existing null values, you have to go with SmallInt.
0
 
FordraidersAuthor Commented:
The default will always be unchecked,."NO"
0
 
Anthony PerkinsCommented:
SQL server only allows two for bit data types which is the obvious conversion path.  
You may want to double check that.  A bit data type allows 1, 0 or NULL.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
PatHartmanCommented:
Looks like you are correct.  I wonder if that is a change in newer versions of SQL Server or if the problem was in fact caused by the upsizing wizard marking these fields as required.  I guess I'll never know.  Today Bit works fine.
0
 
FordraidersAuthor Commented:
ok, I added a field to the sql server table  "smallint"

I have a checkbox in my subform now, but the checkbox will not let me check or uncheck.

The the values in the field are 0(uncheck) and 1(check)
But the checkbox stays a blue color ?

Thanks
fordraiders
0
 
PatHartmanCommented:
Is it bound? Did you just add the checkbox or did you mess with its properties?  Is the form updateable?  Is the underlying query updateable?
0
 
FordraidersAuthor Commented:
IT IS BOUND....just the default value  = 1
0
 
PatHartmanCommented:
I count 4 questions and I see 1 answer.
0
 
FordraidersAuthor Commented:
Is it bound?   YES
Did you just add the checkbox ?  yes, ADDED IT
or did you mess with its properties?  just the default value  = 1
Is the form updateable? YES
Is the underlying query updateable? YES
ALLOW EDITS  =  YES on both forms
0
 
PatHartmanCommented:
Is the control enabled and unlocked?
0
 
FordraidersAuthor Commented:
enabled =  yes
locked  =  no
0
 
FordraidersAuthor Commented:
at the bottom of the screen, The error message, The Control cant be edited, its bound to an unknown field  "SKU_THRESHOLD"
WHICH IS THE CORRECT NAME...
0
 
PatHartmanCommented:
Access disagrees.  This is a battle you can't win.  You'll have to find the typo.
0
 
FordraidersAuthor Commented:
Pat, Lets go a different route.
If i keep it unbound.
I have 5 lines in the subform.
and make a check in the first box. NOW
"all the boxes" are marked with a check ?
If i take the check out, All the lines are taken out.



dp
0
 
FordraidersAuthor Commented:
pat, ok...I added the actual field the checkbox is bound to on the subform.
Now it will let me at least check the checkbox.
and
it adds the value to the field.  "TRUE" or "FALSE"

however, now it wont let me check more than One Checkbox.. ?
0
 
FordraidersAuthor Commented:
nm, Just aint workin.
0
 
PatHartmanCommented:
I'm glad you moved away from the unbound route.  It is possible on a single form but on a continuous form, you get everything set to the value from the current record as you saw.  That is because multi-record forms are simply multiple instances of a single record form.  when there is bound data, that works fine but since there is only one set of properties, all visible instances show the same value because there is only one value.
ok...I added the actual field the checkbox is bound to on the subform.
Hadn't you done that before?
however, now it wont let me check more than One Checkbox.. ?
I can't picture what you are doing.  Are you talking about multiple checkboxes on one record or the same field on different rows?
0
 
FordraidersAuthor Commented:
subform checkbox
Pat trying this..this is the subform
0
 
PatHartmanCommented:
1. There is a problem with the Send field.  Is it bound?  Is the bound field used any where else on the form?
2. Check32 really should have a proper name.
0
 
FordraidersAuthor Commented:
Pat, Here is what i had to do.   I changed the combox to a Yes,No choice.
But bound the choices to a seperate table.
I then stored the value chosen (from the combobox)in the sql server field..
it is storing it as   "1" or "2" in the field.
0
 
PatHartmanCommented:
The combo itself is bound to the RecordSource of the form or report.  The RowSource of the Combo (this is what produces the list of choices), can be bound to a table or query different from the form's RecordSource and usually is.  Sometimes for short, unchanging lists, you might use a ValueList instead of a table or query.
0
 
FordraidersAuthor Commented:
Thanks very much !
0
 
PatHartmanCommented:
You're welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 12
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now