S
sheela
I have already spent almost a day on this with out any
success. I really appreciate any help on this issue.
I am working on a freezers database for a lab. This will
store and maintain the data of samples in multiple
freezers.
I am using a form to add multiple records (for
simultaneous positions) to the table. The user specifies
start position and end position in the form. Then this
form adds multiple records to the table, all fields having
same value except the position field will differ, runs
through the start position and end position.
The table has a unique index to prevent storing more than
one sample in a position. If there is already a sample
stored in a position, say 15. Using this form if we
specify to enter from position 10 to 20, then it will add
into the position 10, and gives an error about the index.
I don't want to add any records if any of the start
position through end position is already filled in. I
would really appreciate if some body could help me.
Right now I am using the code as follows. Even I am
using "DoCmd.RunCommand acCmdDeleteRecord" there is still
one record is being added to the table.
Private Sub cmdSaveClose_Click()
Dim k As Integer
On Error GoTo Err_cmdSaveClose_Click
With Me.RecordsetClone
For k = Me.txtStartPosition.Value To
Me.txtEndPosition.Value
.AddNew
!RecordID = Me!RecordID
!Position = k
!TrialName = Me!TrialName
!FreezerName = Me!cmbFreezerName
!RackNumber = Me!cmbRackNumber
!Box = Me!cmbBox
!SampleId = Me!txtSampleId
!SampleType = Me!cmbSampleTyp
!Storedby = Me!txtStoredby
!StoredDate = Me!txtStoredDate
!StorageTemp = Me!txtStorageTemp
.Update
Next k
End With
DoCmd.Close
Exit_cmdSaveClose_Click:
Exit Sub
Err_cmdSaveClose_Click:
If Err.Number = 3022 Then
MsgBox ("Sorry, ...")
DoCmd.RunCommand acCmdDeleteRecord
Else: MsgBox "Error No: " & Err.Number & ";
Description: " & Err.Description
Resume Exit_cmdSaveClose_Click
End If
DoCmd.Close
End Sub
success. I really appreciate any help on this issue.
I am working on a freezers database for a lab. This will
store and maintain the data of samples in multiple
freezers.
I am using a form to add multiple records (for
simultaneous positions) to the table. The user specifies
start position and end position in the form. Then this
form adds multiple records to the table, all fields having
same value except the position field will differ, runs
through the start position and end position.
The table has a unique index to prevent storing more than
one sample in a position. If there is already a sample
stored in a position, say 15. Using this form if we
specify to enter from position 10 to 20, then it will add
into the position 10, and gives an error about the index.
I don't want to add any records if any of the start
position through end position is already filled in. I
would really appreciate if some body could help me.
Right now I am using the code as follows. Even I am
using "DoCmd.RunCommand acCmdDeleteRecord" there is still
one record is being added to the table.
Private Sub cmdSaveClose_Click()
Dim k As Integer
On Error GoTo Err_cmdSaveClose_Click
With Me.RecordsetClone
For k = Me.txtStartPosition.Value To
Me.txtEndPosition.Value
.AddNew
!RecordID = Me!RecordID
!Position = k
!TrialName = Me!TrialName
!FreezerName = Me!cmbFreezerName
!RackNumber = Me!cmbRackNumber
!Box = Me!cmbBox
!SampleId = Me!txtSampleId
!SampleType = Me!cmbSampleTyp
!Storedby = Me!txtStoredby
!StoredDate = Me!txtStoredDate
!StorageTemp = Me!txtStorageTemp
.Update
Next k
End With
DoCmd.Close
Exit_cmdSaveClose_Click:
Exit Sub
Err_cmdSaveClose_Click:
If Err.Number = 3022 Then
MsgBox ("Sorry, ...")
DoCmd.RunCommand acCmdDeleteRecord
Else: MsgBox "Error No: " & Err.Number & ";
Description: " & Err.Description
Resume Exit_cmdSaveClose_Click
End If
DoCmd.Close
End Sub