Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Micosoft Access Question. 1

Status
Not open for further replies.

AliThePro

Mechanical
Jan 13, 2005
57
This question is about Access 2000. I have a form with lables, text boxes, etc. which is linked to a table. If the table is empty (no records), then when the form comes up there is nothing on the form even the lables. But, when I populate the table with some records then the table comes up fine. I do not understand this behavior, I appreciate your comments.

Ali
 
Replies continue below

Recommended for you

When a form that is bound to a table initially loads, part of the initialization process is the populate the controls. Since the form's recordset is empty, the initialization fails. One workaround is to add a record to the table in the Form_Load event of the form.
Code:
Private Sub Form_Load()

   If ((rFrm_Form.Recordset.BOF) And (rFrm_Form.Recordset.EOF)) Then
      With Me.Recordset
         .AddNew
         .Fields("<one of the fields>") = <default value>
         .Update
      End With
   End If

End Sub

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thank you for your response. But shouldn't I receive some kind of error? Personally, I think the correct behavior is for the form to come up with empty textboxes rather than fail to come up if there is no record in the table.

Ali
 
That's a fair question, but one that should be directed at the Access 2000 Development Team. As far as I know, that's just the way it works.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor