1
votes

I have a form with a few bound fields and a few 'custom made' checkboxes, which set values per vba. When I now start a new record with 'DoCmd.GoToRecord , , acNewRec', Access clears my form but won't create a fresh ID until a value is entered into one of the bound fields. Since my checkbox-fields are not bound, any changes before a bound field has been edited won't be saved. I tried adding values via sql statements, but access throws an error after I change another field stating that the current recordset has been changed so I doubt that this is the way to go.

My form is based on a query and witch vba I set the checkboxes like [value_x] = true (which works fine when I first enter data into a bound field and thereby a new record is created).

(Another way to avoid this would be to set any bound field during the onload-event to a value and remove the value afterwards. But that's not very clean I guess ..)

1
This is by design... If you want to force a new ID in there ahead of time, you will need to perform a create/edit cycle. Why are your checkboxes not bound?Robert Harvey
The normal checkboxes are to small for my formulars, so I use labelfields with onclick-events and 'X' inside. They look better and can be a lot larger, but can't be bound (as far as I know?). I know that the activex checkboxes are resizeable but I haven't tested them yet.Christian
I solved this problem once before, but I no longer have access to the original code. I believe what I did was wire up an OnClick event to my custom checkbox, and used that to change the value of a hidden checkbox that was bound to the underlying recordset.Robert Harvey
Good idea, that should work! I'll give it a try. Ty :)Christian

1 Answers

1
votes

After testing a few approaches I found my earlier stated idea to be the easiest approach. This means I set a value of a bound field in the form_load event and work with me.dirty where neccessary.

Of course I have to delete empty recordsets afterwards (if someone only opens and closes the form), but that can be handled very easy.

Another great idea was the one Robert Harvey gave me. He suggested to add a click event to my unbound custom checkboxes and use this to change a hidden bound checkbox field, which also worked great.