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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not allowing Blank records 1

Status
Not open for further replies.

bkrampe

IS-IT--Management
Nov 30, 2006
77
US
I have a form that adds records and a form that is supposed to delete records in the same table. But when i try and delete the record, it only deletes the information and leaves the blank record in the table. Any help on how i can get rid of the blank records? Thanks in advance.
 
It's difficult to answer without details of how you are deleting your records at the moment. What's your code? Bound or unbound form?

Ed Metcalfe.

Please do not feed the trolls.....
 
Are you looking at the table to see these "blank"records, or are you looking at the form, which will display a blank record as default?

"Before you criticize someone, you should walk a mile in their shoes.
That way, when you criticize them, you're a mile away and you have their shoes."
 
I have the normal add button code that access puts in for me when i create the button. And my delete button code is as follows:

Private Sub DeleteRecord_Click()
Dim rst As DAO.Recordset, Cri As String, SQL As String
Dim Msg As String, Style As Integer, Title As String

Cri = "[MaterialCode] = '" & Me!MaterialCode & "' AND " & _
"[Y-Dimension] = '" & Me![Y-Dimension] & "' AND " & _
"[X-Dimension] = '" & Me![X-Dimension] & "'"

Set rst = Me.RecordsetClone
rst.FindFirst Cri

If rst.NoMatch Then
Msg = "Combined BarCode Record Not Found or Doesn't Exist!"
Style = vbInformation + vbOKOnly
Title = "Can't Find Combined BarCode! . . ."
MsgBox Msg, Style, Title
Else
SQL = "DELETE FROM REF " & _
"WHERE " & Cri
DoCmd.RunSQL SQL
End If

Set rst = Nothing
End Sub
 
How are ya bkrampe . . .
bkrampe said:
[blue]I have a form that adds records and a form that is supposed to delete records in the same table. But when i try and delete the record, it only deletes the information and leaves the blank record in the table.[/blue]

Post the code for both! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Here is the code for the Add button.

Private Sub AddRecord_Click()
On Error GoTo Err_AddRecord_Click


DoCmd.GoToRecord , , acNewRec

Exit_AddRecord_Click:
Exit Sub

Err_AddRecord_Click:
MsgBox Err.Description
Resume Exit_AddRecord_Click

End Sub
 
bkrampe . . .

Try the following SQL instead:
Code:
[blue]
SQL = "DELETE  Ref.[purple][b][i]PrimaryKeyName[/i][/b][/purple] " & _
      "FROM REF " & _
      "WHERE " & Cri[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Hey that works great. But now we ran into another problem, that goes along with one of my other posts. Thanks a lot for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top