The following code is causing a problem in my db.
On Error GoTo Errtrap
DoCmd.GoToRecord acDataForm, "frmImage", acNewRec
Forms!frmImage!EstimateNo = Forms!frmdetails!EstimateNo
Forms!frmImage!Supp = Forms!frmdetails!Supp
Me.cmdlgpicture.InitDir = "L:\home"
Me.cmdlgpicture.Filter = " Image (*.jpg)|*.jpg"
Me.cmdlgpicture.ShowOpen
Me.olepicture.SourceDoc = Me.cmdlgpicture.FileName
If Me.cmdlgpicture.FileName <> "" Then
Me.olepicture.SizeMode = acOLESizeStretch
Me.olepicture.Action = acOLECreateLink
End If
Exit Sub
Errtrap:
If their is a record already in the table, it works fine.
Adds a new record as it should.
If their is no record and the code is activated,it adds a new record leaving a blank record in the table along with the newly created one.
I know the cause is the first line "acnew etc" but don't know how to bypass this.
Ideally, when the form opens and their are no records to start with, a msgbox to tell the user, their are no records, do you want to add would be great.
Can some-one help
Dave
On Error GoTo Errtrap
DoCmd.GoToRecord acDataForm, "frmImage", acNewRec
Forms!frmImage!EstimateNo = Forms!frmdetails!EstimateNo
Forms!frmImage!Supp = Forms!frmdetails!Supp
Me.cmdlgpicture.InitDir = "L:\home"
Me.cmdlgpicture.Filter = " Image (*.jpg)|*.jpg"
Me.cmdlgpicture.ShowOpen
Me.olepicture.SourceDoc = Me.cmdlgpicture.FileName
If Me.cmdlgpicture.FileName <> "" Then
Me.olepicture.SizeMode = acOLESizeStretch
Me.olepicture.Action = acOLECreateLink
End If
Exit Sub
Errtrap:
If their is a record already in the table, it works fine.
Adds a new record as it should.
If their is no record and the code is activated,it adds a new record leaving a blank record in the table along with the newly created one.
I know the cause is the first line "acnew etc" but don't know how to bypass this.
Ideally, when the form opens and their are no records to start with, a msgbox to tell the user, their are no records, do you want to add would be great.
Can some-one help
Dave