Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Problem with form fields (They won't clear)

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have the following code that adds records and closes the form. The problem is, whenver i add a record, close a form and reopen it, i still see the previous added data in the form. They won't clear. Can anybody give me the solution please?

Thanks



Private Sub Add_Click()
On Error GoTo Err_Add_Click
Dim i

DoCmd.GoToRecord , , acNewRec
Me!Text23 = ""
Me!Text45 = ""
Me!City = ""
Exit_Add_Click:
Exit Sub

Err_Add_Click:
If Err.Number = 3022 Then
i = MsgBox(" The Student ID Has To Be Unique", vbOKOnly, "Student Database")
Else
MsgBox Err.Description
Resume Exit_Add_Click
End If

End Sub

Private Sub Close_Click()
On Error GoTo Err_Close_Click

DoCmd.Close

Exit_Close_Click:
Exit Sub

Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click

End Sub
 
Well that the way Access works by default.
If you do not want to se the data then you have to make it an unbound form and write your own code to do everything.

If say you are opening your foam and you wan to find something then you can do it easily when its Bound.

If you want to add a new record then create an "Add-New-Record" button which will then blank out all fields.
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Are you saying you always want a blank form, and you don't intend to use it to review and update records? Then you can just set the Allow Additions and Data Entry properties to Yes. The form will then open to a New record, and will only allow record additions.

On the other hand, if you want to allow review and update but always want to open to a new, empty record, put the following statement in the form's Open event procedure:
Me.NewRecord

Going to a New record will automatically clear all the bound fields. I don't understand why you say they're not clearing, unless they're unbound fields. But I don't understand why you'd be using unbound fields if you're updating a recordset. Am I missing something? Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top