blank records inserted automatically

lscheer

Registered User.
Local time
Today, 23:40
Joined
Jan 20, 2000
Messages
185
I have posted this concern before, but I was mis-understanding what was causing it...in actuality, I don't know what's causing it, which is why I'm posting the question here.

Whenever any users enter data into the main table via a form based on the table (not on a query of the table), a blank record is inserted after the current record so that if you navigate to the final record, it is not the one you just entered, but a totally blank one.

I can tell these are just accidental blank records, because the one field with a default value (a Yes/No field with a Yes; No Value List) displays a -1 (since "Yes" is the default value), where all the others display "yes" or "no".


This is the only code attached to the form itself (note: "current info" is the field mentioned above):

Private Sub Form_BeforeUpdate(Cancel As Integer)

'Date modified
Me!ContactInfoModifiedBy = CurrentUser()
Me!ContactDateModified = Now()


If Me.CurrentInfo = "No" Or Me.chkBlacklisted = -1 Then
Me.CourseCatalog = 0
Me.OmitFromAllMailings = -1
End If

End Sub

Private Sub Form_LostFocus()
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close

End Sub




Any Ideas?
 
Why do you have a Yes/No field with a value list saving what looks like a string?
 
It's not saving the strings ("yes"/"no"), I know Y/N fields save -1 and 0, respectively, the value list is just used for display purposes....I'm not even sure that has anything to do with the problem, it's just figured I'd provide as much info as possible.
 
I have removed this code from the form, but the blank records are still appearing...any other ideas?
 
This doesn't really help because the event I think is making this happen is running a macro, and I tried taking the SaveRecord Command out of the macro, but it still does it (adds the blank record, that is).

The macro is supposed to search for the person in a form and if it doesn't find them, then add their ID number to the forms underlying table so that their data can be displayed in both forms without being actually stored in two separate locations. THe macro used to work fine, and now when I run it, it adds this extra record at the end of the first form.

When I set a non-key field's required property to Yes, i just get stuck on the error message that I can't add a null record because one of it's fields is set to required. It doesn't really get me anywhere closer to figuring out what's wrong...
 
Here is the macro converted into VBA. Any help figuring out why this is doing this would be much appreciated! When I try to run the break on all errors as pat suggested above, the code dumps me into the Requery"" line.

Function mcrOpen_Find_Appl()
On Error GoTo mcrOpen_Find_Appl_Err

DoCmd.Echo False, "Running..."
If (Forms!frmContacts!AIAQTPApplicant = False) Then
Exit Function
End If
If (Forms!frmContacts!AIAQTPApplicant = True) Then
DoCmd.OpenForm "frmApplicants", acNormal, "", "", acEdit, acNormal
DoCmd.GoToControl "[ApplID]"
DoCmd.FindRecord Forms!frmContacts!ContactID, acEntire, False, , False, , True
End If
If (Forms!frmContacts.ContactID <> Forms!frmApplicants.ApplID) Then
DoCmd.GoToRecord acForm, "frmApplicants", acNewRec
Forms!frmApplicants!ApplID = Forms!frmContacts!ContactID
DoCmd.Requery ""
DoCmd.GoToControl "ApplID"
DoCmd.FindRecord Forms!frmContacts!ContactID, acEntire, False, , False, , True
End If
DoCmd.Close acForm, "frmContacts"


mcrOpen_Find_Appl_Exit:
Exit Function

mcrOpen_Find_Appl_Err:
MsgBox Error$
Resume mcrOpen_Find_Appl_Exit

End Function
 
I tried splitting the macro up at the place suggested, and putting the steps from SetValue (...ApplID=...ContactID) on the Before Insert event of the Applicants form but what happens is the Applicants form opens to a blank record. If I hit a data entry key (spacebar, or an alphanumeric key), the record is populated with existing data as it should be. However, the common user would have to be instructed to do that on their own, whereas they're used to seeing the data populated automatically.

Aside from which, the blank records are still being inserted...
 

Users who are viewing this thread

Back
Top Bottom