yessir
Saved By Grace
- Local time
- Today, 01:49
- Joined
- May 29, 2003
- Messages
- 349
Ok, I know I have posted about this before, but I really have to resolve this.
I have a form where by I am doing checks on data to see if the imported values are existing in a maintanence table.
So after all the data is imported I am cycling through each record checking if the entered value for Matrix is in the maintenance table and
1) if it is then ok,
2) if it is not then,
a) ask if want to enter it into the Matrix as a valid value, or
b) choose a value to enter in it's place.
I have the existing code working for all but case 2-b.
I wish to have a module with the following code which if the case of 2-b occurs it will stop processing the records till a value is chosen from a popup form containing a dropdown (as included). Once the value is chosen it starts looping through again and doing checks .
Now I am told it is not possible to "Stall" the loop and wait for a return of a value.
The code always does work on the first record (as it stands) so even just stoping the loop, opening the form, and starting the loop again after teh return of the value would be fine.
I am REALLY in need of assistance here.
VERY DESPERATE!
~
I have a form where by I am doing checks on data to see if the imported values are existing in a maintanence table.
So after all the data is imported I am cycling through each record checking if the entered value for Matrix is in the maintenance table and
1) if it is then ok,
2) if it is not then,
a) ask if want to enter it into the Matrix as a valid value, or
b) choose a value to enter in it's place.
I have the existing code working for all but case 2-b.
I wish to have a module with the following code which if the case of 2-b occurs it will stop processing the records till a value is chosen from a popup form containing a dropdown (as included). Once the value is chosen it starts looping through again and doing checks .
Now I am told it is not possible to "Stall" the loop and wait for a return of a value.
The code always does work on the first record (as it stands) so even just stoping the loop, opening the form, and starting the loop again after teh return of the value would be fine.
I am REALLY in need of assistance here.
VERY DESPERATE!
~

Code:
Private Sub Command30_Click()
Dim DB As DAO.Database
Dim RS As DAO.Recordset
Dim NumRec As Integer
Dim i As Integer
Dim cont As Boolean
Set DB = CurrentDb
Set RS = DB.OpenRecordset("tblWater_Sample_Temp")
i = 1
'Move to the last record
RS.MoveLast
NumRec = RS.RecordCount
RS.MoveFirst
'ONLY do the following if there are records to work on
If NumRec >= 1 Then
cont = True
'Cycle through each record in the tables record set
While i <= NumRec
'Go to the first record as each time there is a record appended from the top to the bottom
' And then the first record is deleted
RS.MoveFirst
'Look up the values in the tables on the form to ensure they are valid in the maintanence tables
If IsNull(DLookup("ID", "tblMatrix", "Matrix = Forms!frmWater_Sample_Import.frmWater_Sample_Import_Temp.Form.Matrix.Value")) Then
MsgBox "" & i & " > NULL > " & DLookup("ID", "tblMatrix", "Matrix = Forms!frmWater_Sample_Import.frmWater_Sample_Import_Temp.Form.Matrix.Value")
If MsgBox("Would you like to ADD this NEW VALUE?", vbYesNo, "Value Not Valid") = vbYes Then
'Set warnings void
'Insert the new value into the table
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblMatrix ( Matrix ) SELECT tblWater_Sample_Temp.Matrix FROM tblWater_Sample_Temp WHERE (((tblWater_Sample_Temp.Matrix)=Forms!frmWater_Sample_Import.frmWater_Sample_Import_Temp.Form.Matrix.Value));"
DoCmd.SetWarnings True
Else
DoCmd.OpenForm ("frmRecEdit")
Screen.ActiveForm.cboMatrix.Enabled = True
Screen.ActiveForm.cboMatrix.Visible = True
Screen.ActiveForm.cboMatrix_Label.Visible = True
' DoCmd.Close acForm, "frmRecEdit"
' RS.Edit
' RS.Fields("Matrix") = Me.hidden_temp
' Me.hidden_temp = ""
End If
End If
i = i + 1
'Appends the first entry of the table onto the end of the table
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblWater_Sample_Temp ( ClientID, ProjectNo, LabID, Matrix, DuplicateOf, SampleDate, Analyte, Method, Result, Units, LOQ, Outlet_ID, Elevation, Unit_ID, DataSource, [Note], DL, FlowValue, FlowUnit_ID, Notes, Duplicate ) SELECT TOP 1 tblWater_Sample_Temp.ClientID, tblWater_Sample_Temp.ProjectNo, tblWater_Sample_Temp.LabID, tblWater_Sample_Temp.Matrix, tblWater_Sample_Temp.DuplicateOf, tblWater_Sample_Temp.SampleDate, tblWater_Sample_Temp.Analyte, tblWater_Sample_Temp.Method, tblWater_Sample_Temp.Result, tblWater_Sample_Temp.Units, tblWater_Sample_Temp.LOQ, tblWater_Sample_Temp.Outlet_ID, tblWater_Sample_Temp.Elevation, tblWater_Sample_Temp.Unit_ID, tblWater_Sample_Temp.DataSource, tblWater_Sample_Temp.Note, tblWater_Sample_Temp.DL, tblWater_Sample_Temp.FlowValue, tblWater_Sample_Temp.FlowUnit_ID, tblWater_Sample_Temp.Notes, tblWater_Sample_Temp.Duplicate FROM tblWater_Sample_Temp;"
DoCmd.SetWarnings True
'Deletes the first entry in the table as is now a dulicate
RS.Delete
'Refresh the subforms record source so the deleted values do not appear to the user
Me.frmWater_Sample_Import_Temp.Form.RecordSource = "SELECT * FROM tblWater_Sample_Temp;"
Wend
End If
'Empty the reserved memory of rst & myDb
Set RS = Nothing
Set DB = Nothing
End Sub
Attachments
Last edited by a moderator: