controls disappear when form opened readonly

  • Thread starter Thread starter mike lee
  • Start date Start date
M

mike lee

hello,
I'm fairly new at Access, and have a question. I have a
query which diplays its results in a form. If the query
returns no results, the form's fields display "Not
found." When that happens, when you try to close the
form, you get "Index or Primary Key can not contain a
null value." I've tried setting Allow Edits, Allow
Deletions and Allow Additions to "no", and I've also
tried changing the command that opens the form to:

DoCmd.OpenForm "frmDomName", acNormal, , ,
acFormReadOnly, acWindowNormal

When I do this, I no longer get the error, but all of the
controls disappear. I tried putting a loop in the
form_current event

for each cntrl in me.controls
cntrl.visible = true
next cntrl

but that didn't do anything either.

So, anyone have any ideas how I can get rid of that error
but still be able to see my data? Any help would be
greatly appreciated. (Access2000, Office2000, XP Pro).

Thanks,
Mike
 
mike lee said:
hello,
I'm fairly new at Access, and have a question. I have a
query which diplays its results in a form. If the query
returns no results, the form's fields display "Not
found." When that happens, when you try to close the
form, you get "Index or Primary Key can not contain a
null value." I've tried setting Allow Edits, Allow
Deletions and Allow Additions to "no", and I've also
tried changing the command that opens the form to:

DoCmd.OpenForm "frmDomName", acNormal, , ,
acFormReadOnly, acWindowNormal

When I do this, I no longer get the error, but all of the
controls disappear. I tried putting a loop in the
form_current event

for each cntrl in me.controls
cntrl.visible = true
next cntrl

but that didn't do anything either.

So, anyone have any ideas how I can get rid of that error
but still be able to see my data? Any help would be
greatly appreciated. (Access2000, Office2000, XP Pro).

Thanks,
Mike

Any time a bound form has no records to display and it isn't possible to
add any -- as for example if the form is read-only, or AllowAdditions is
False, or the recordsource is not updatable -- the form's detail section
will be entirely blank. My guess is that you are doing something in the
form's Open, Load, or Current event that "dirties" the form (modifies
some bound control), and that's why you get the error when there are no
records to display and additions are allowed, but not when additions are
not allowed. Check into that code and see whether you can forestall it
with a preliminary test to see if the form's recordset contains any
records.
 
Back
Top