Data being erased.

  • Thread starter cableguy47905 via AccessMonster.com
  • Start date
C

cableguy47905 via AccessMonster.com

I am having trouble with data being erased in my form. It seems to be a bug,
or something. It only seems to be in this one subform. Not all the time,
but it does seem to happen most often with the first change in a record. It
will erase all of the data just before moving to the next record. I have
also noticed that sometimes when I click to add a record, it goes to the new
record, but then goes right back to the record I was on.

Does anyone know about anything that would cause this?

Thanks,
Lee
 
C

cableguy47905 via AccessMonster.com

Sure can.

Keep in mind that I am a novice when it comes to coding.

Thanks in advance.

This is the sub form:

Option Compare Database

Private Sub CboMapStatus_BeforeUpdate(Cancel As Integer)
Me.Date.Value = Now()
Me.txtUser.Value = CurrentUser()
End Sub

Private Sub CboMapStatus_GotFocus()
Me.TxtCompanyName = [Forms]![Contact Info]![CompanyName]
Me.TxtContractNumber = [Forms]![Contact Info]![ContractNumbers]

End Sub

Private Sub CboMapStatus_AfterUpdate()
On Error GoTo Err_CboMapStatus_AfterUpdate_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Dim x As Object
Dim strSubject As String
Dim strBody As String
Dim stDocName As String

stDocName = "RPT_MapRequestPCM"

Dim stDefault As String

stDefault = ""


Me.TxtComments.DefaultValue = stDefault
Me.TxtFieldsIgnore.DefaultValue = stDefault
Me.TxtFtpFilename.DefaultValue = stDefault
Me.CboBusinessNeed.DefaultValue = stDefault
Me.CboFileFormat.DefaultValue = stDefault
Me.CboMapStatus.DefaultValue = stDefault
Me.CboRequestType.DefaultValue = stDefault
Me.CboSubmittype.DefaultValue = stDefault
Me.CboMapAssign.DefaultValue = stDefault
Me.TxtFtpLogin.DefaultValue = stDefault
Me.TxtIgnoreFields.DefaultValue = stDefault
Me.TxtLogic.DefaultValue = stDefault
Me.TxtLogicNeeded.Value = stDefault
Me.TxtMultipleMaps.DefaultValue = stDefault
Me.TxtPassword.DefaultValue = stDefault
Me.TxtPped.DefaultValue = stDefault
Me.TxtTestFile.DefaultValue = stDefault
Me.TxtTransferDate.DefaultValue = stDefault
Me.TxtRevisionChange.DefaultValue = stDefault
Me.CboMapAssign.DefaultValue = stDefault
Me.TxtTargetDate.DefaultValue = stDefault

If MsgBox("Do you really want to do this?", vbYesNo) = vbYes Then

DoCmd.SendObject acReport, stDocName, "Rich Text", "DeHaai.Wendi@principal.
com; (e-mail address removed); (e-mail address removed); Yochum.
(e-mail address removed); (e-mail address removed); Burch.Robert@principal.
com; (e-mail address removed)", , , Me.CboRequestType.Value & " for: " &
Me.TxtCompanyName & " - " & Me.TxtContractNumber



End If
Exit_CboMapStatus_AfterUpdate_Click:
Exit Sub

Err_CboMapStatus_AfterUpdate_Click:
MsgBox Err.Description
Resume Exit_CboMapStatus_AfterUpdate_Click


End Sub


Private Sub CmdClear_Click()

On Error GoTo Err_CmdClear_Click
Dim stDefault As String

stDefault = ""


Me.TxtComments.DefaultValue = stDefault
Me.TxtFieldsIgnore.DefaultValue = stDefault
Me.TxtFtpFilename.DefaultValue = stDefault
Me.CboBusinessNeed.DefaultValue = stDefault
Me.CboFileFormat.DefaultValue = stDefault
Me.CboMapStatus.DefaultValue = stDefault
Me.CboRequestType.DefaultValue = stDefault
Me.CboSubmittype.DefaultValue = stDefault
Me.CboMapAssign.DefaultValue = stDefault
Me.TxtFtpLogin.DefaultValue = stDefault
Me.TxtIgnoreFields.DefaultValue = stDefault
Me.TxtLogic.DefaultValue = stDefault
Me.TxtLogicNeeded.Value = stDefault
Me.TxtMultipleMaps.DefaultValue = stDefault
Me.TxtPassword.DefaultValue = stDefault
Me.TxtTargetDate.DefaultValue = stDefault
Me.TxtPped.DefaultValue = stDefault
Me.TxtTestFile.DefaultValue = stDefault
Me.TxtTransferDate.DefaultValue = stDefault
Me.TxtRevisionChange.DefaultValue = stDefault
Me.CboMapAssign.DefaultValue = stDefault
Me.TxtTargetDate.DefaultValue = stDefault

Exit_CmdClear_Click:
Exit Sub

Err_CmdClear_Click:
MsgBox Err.Description
Resume Exit_CmdClear_Click

End Sub

Private Sub Form_Current()
Me.TxtCompanyName = [Forms]![Contact Info]![CompanyName]
Me.TxtContractNumber = [Forms]![Contact Info]![ContractNumbers]
End Sub
Private Sub cmdSetDefaults_Click()
On Error GoTo Err_cmdSetDefaults_Click

Me.TxtComments.DefaultValue = """" & Me.TxtComments.Value & """"
Me.TxtFieldsIgnore.DefaultValue = """" & Me.TxtFieldsIgnore.Value & """"
Me.TxtFtpFilename.DefaultValue = """" & Me.TxtFtpFilename.Value & """"
Me.CboBusinessNeed.DefaultValue = """" & Me.CboBusinessNeed.Value & """"
Me.CboFileFormat.DefaultValue = """" & Me.CboFileFormat.Value & """"
Me.CboMapStatus.DefaultValue = """" & Me.CboMapStatus.Value & """"
Me.CboRequestType.DefaultValue = """" & Me.CboRequestType.Value & """"
Me.CboSubmittype.DefaultValue = """" & Me.CboSubmittype.Value & """"
Me.CboMapAssign.DefaultValue = """" & Me.CboMapAssign.Value & """"
Me.TxtFtpLogin.DefaultValue = """" & Me.TxtFtpLogin.Value & """"
Me.TxtIgnoreFields.DefaultValue = """" & Me.TxtIgnoreFields.Value & """"
Me.TxtLogic.DefaultValue = """" & Me.TxtLogic.Value & """"
Me.TxtLogicNeeded.DefaultValue = """" & Me.TxtLogicNeeded.Value & """"
Me.TxtMultipleMaps.DefaultValue = """" & Me.TxtMultipleMaps.Value & """"
Me.TxtPassword.DefaultValue = """" & Me.TxtPassword.Value & """"
Me.TxtPped.DefaultValue = """" & Me.TxtPped.Value & """"
Me.TxtRevisionChange.DefaultValue = """" & Me.TxtRevisionChange.Value &
""""
Me.TxtTargetDate.DefaultValue = """" & Me.TxtTargetDate.Value & """"
Me.TxtTestFile.DefaultValue = """" & Me.TxtTestFile.Value & """"
Me.TxtTransferDate.DefaultValue = """" & Me.TxtTransferDate.Value & """"


Exit_cmdSetDefaults_Click:
Exit Sub

Err_cmdSetDefaults_Click:
MsgBox Err.Description
Resume Exit_cmdSetDefaults_Click

End Sub



Private Sub CmdDel_Click()
On Error GoTo Err_CmdDel_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_CmdDel_Click:
Exit Sub

Err_CmdDel_Click:
MsgBox Err.Description
Resume Exit_CmdDel_Click

End Sub
Private Sub CmdUndo_Click()
On Error GoTo Err_CmdUndo_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

Exit_CmdUndo_Click:
Exit Sub

Err_CmdUndo_Click:
MsgBox Err.Description
Resume Exit_CmdUndo_Click

End Sub



Here is the Main form:

Option Compare Database

Private Sub AST_AfterUpdate()
txtAsst_ID.Value = AST.Column(0)
txtCSA_Asst_Number.Value = AST.Column(2)
txtCSA_Asst_Email.Value = AST.Column(3)
End Sub

Private Sub AST_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
Dim CSA As AccessObject

strMsg = "'" & NewData & "' is not in our list. " & vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to add " & NewData & " to the list? "
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to add or No to re-type it.
"

If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo Then
Set db = CurrentDb
Set rs = db.OpenRecordset("TBL_CSA_Asst_List", dbOpenDynaset)
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("TBL_CSA_Asst_List", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!AST = NewData
rs.Update

If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded

End If
End If

rs.Close
Set rs = Nothing
Set db = Nothing

End Sub

Private Sub CmdSaveRec_Click()
On Error GoTo Err_CmdSaveRec_Click

TxtLastUpdated.Value = Now()
TxtUpdatedBy.Value = CurrentUser()

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_CmdSaveRec_Click:
Exit Sub

Err_CmdSaveRec_Click:
MsgBox Err.Description
Resume Exit_CmdSaveRec_Click

End Sub


Private Sub CSCCSA_AfterUpdate()
txtCSA_ID.Value = CSCCSA.Column(0)
txtCSA_Number.Value = CSCCSA.Column(2)
txtCSA_Email.Value = CSCCSA.Column(3)

End Sub


Private Sub CSCCSA_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
Dim CSA As AccessObject

strMsg = "'" & NewData & "' is not in our list. " & vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to add " & NewData & " to the list? "
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to add or No to re-type it.
"

If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo Then
Set db = CurrentDb
Set rs = db.OpenRecordset("TBL_CSA_List", dbOpenDynaset)
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("TBL_CSA_List", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!CSCCSA = NewData
rs.Update

If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded

End If
End If


rs.Close
Set rs = Nothing
Set db = Nothing



End Sub



Private Sub Form_BeforeUpdate(Cancel As Integer)
TxtLastUpdated.Value = Now()
TxtUpdatedBy.Value = CurrentUser()

End Sub

Private Sub Form_Current()
txtCSA_ID.Value = CSCCSA.Column(0)
txtCSA_Number.Value = CSCCSA.Column(2)
txtCSA_Email.Value = CSCCSA.Column(3)
txtAsst_ID.Value = AST.Column(0)
txtCSA_Asst_Number.Value = AST.Column(2)
txtCSA_Asst_Email.Value = AST.Column(3)
End Sub




Private Sub Text94_AfterUpdate()
Me.Text94.Value = "FLE3.CGS.PN.ER" & Me.Text94.Value
End Sub

Private Sub txtCSA_Asst_Email_Click()
Dim SndEmail As String
SndEmail = "mailto:" & Me.[txtCSA_Asst_Email]
Application.FollowHyperlink Address:=SndEmail
End Sub

Private Sub txtCSA_Asst_Number_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FRM_NewAsst"

stLinkCriteria = "[Asst_ID]=" & Me![txtAsst_ID]

DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

Private Sub txtCSA_Email_Click()
Dim SndEmail As String
SndEmail = "mailto:" & Me.[txtCSA_Email]
Application.FollowHyperlink Address:=SndEmail
End Sub

Private Sub txtCSA_Number_DblClick(Cancel As Integer)

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FRM_NewCSA"

stLinkCriteria = "[CSA_ID]=" & Me![txtCSA_ID]

DoCmd.OpenForm stDocName, , , stLinkCriteria



End Sub
Private Sub CmdRefresh_Click()
On Error GoTo Err_CmdRefresh_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

Exit_CmdRefresh_Click:
Exit Sub

Err_CmdRefresh_Click:
MsgBox Err.Description
Resume Exit_CmdRefresh_Click

End Sub
Can you post the code behind the Form and SubForm so we can take a look.

Daniel P
I am having trouble with data being erased in my form. It seems to be a bug,
or something. It only seems to be in this one subform. Not all the time,
[quoted text clipped - 7 lines]
Thanks,
Lee
 
J

John W. Vinson

Sure can.

Keep in mind that I am a novice when it comes to coding.

Thanks in advance.

This is the sub form:

That's a lot of code to go through without being able to execute it and use
the debugger...

but there's code for a command button cmdUndo that might be the culprit. Is
there such a button on your form? Might it be getting clicked (perhaps
unintentionally)?

Try opening the code in the VBA editor and putting a breakpoint on an
executable statement in cmdUndo (click in the grey bar to the left of the code
window) and see if it's getting fired.

John W. Vinson [MVP]
 
C

cableguy47905 via AccessMonster.com

I actually can't recreate the problem. I know it has happened to me a couple
of times, but it has also happened to several others using the database.

Could it be a sharing thing? Maybe someone else is on the record at the same
time?

I tried your suggestions, but I just can't recreate the problem. It is very
hard to pin down, but it can really cause a pretty big mess because they end
up typing over data in that current record.

Is there a way that I could give a warning box if they are about to save a
record that they are making a change to instead of one that they are adding?
Sure can.
[quoted text clipped - 3 lines]
This is the sub form:

That's a lot of code to go through without being able to execute it and use
the debugger...

but there's code for a command button cmdUndo that might be the culprit. Is
there such a button on your form? Might it be getting clicked (perhaps
unintentionally)?

Try opening the code in the VBA editor and putting a breakpoint on an
executable statement in cmdUndo (click in the grey bar to the left of the code
window) and see if it's getting fired.

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top