Skip to content

Instantly share code, notes, and snippets.

@kissmygritts
Created June 4, 2015 18:22
Show Gist options
  • Save kissmygritts/525585d45f217bb9127a to your computer and use it in GitHub Desktop.
Save kissmygritts/525585d45f217bb9127a to your computer and use it in GitHub Desktop.
Navigate through the records of a recordset.
Sub fill_for_validate(action As String, currentwhno As Integer)
Dim rs As DAO.Recordset
Dim qdef As DAO.QueryDef
Set rs = CurrentDb.OpenRecordset("trans_validate")
Debug.Print currentwhno
If action = "first" Then
rs.MoveFirst
ElseIf action = "next" Then
rs.FindNext ("ID > " & currentwhno)
Debug.Print "Moving to next record" & currentwhno + 1
ElseIf action = "previous" Then
rs.FindNext ("ID < " & currentwhno)
Debug.Print "Moving to next record" & currentwhno - 1
ElseIf action = "last" Then
rs.MoveLast
End If
encounter = rs!barcodeID 'This will need to be cycled for validation, for editing data will pull encounter ID from Specimen Log
For Each fld In rs.Fields
Forms("frmDataEntry").Controls(fld.Name) = fld
Next fld
Procedures.fillmedication (encounter)
Procedures.fillsamples (encounter)
rs.Close
End Sub
Private Sub cmdDataValidation_Click()
Dim sqlstring As String
If Me.txtcValidate = 0 Then
MsgBox "You have no records to validate", 64, "Validation Complete"
Else
sqlstring = "WHERE data_Capture.Validate = 0;"
sql.ValidateEditData (sqlstring)
DoCmd.OpenForm "frmDataEntry"
Procedures.fill_for_validate "first", 0
For Each ctl In Forms("frmDataEntry").Controls
If ctl.Tag = "dataentry" Then
ctl.Visible = False
ElseIf ctl.Tag = "dataedit" Then
ctl.Visible = True
End If
Next ctl
End If
End Sub
Private Sub cmdFirstRecord_Click()
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acListBox, acComboBox
ctl.Value = Null
End Select
Next ctl
Procedures.fill_for_validate ("first"), (0)
End Sub
Private Sub cmdPreviousRecord_Click()
Dim cwhno As String
cwhno = Me.ID
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acListBox, acComboBox
ctl.Value = Null
End Select
Next ctl
Procedures.fill_for_validate ("previous"), (cwhno)
End Sub
Private Sub cmdNextRecord_Click()
Dim cwhno As String
cwhno = Me.ID
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acListBox, acComboBox
ctl.Value = Null
End Select
Next ctl
Procedures.fill_for_validate ("next"), (cwhno)
End Sub
Private Sub cmdLastRecord_Click()
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acListBox, acComboBox
ctl.Value = Null
End Select
Next ctl
Procedures.fill_for_validate ("last"), (0)
End Sub
Private Sub cmdValidateRecord_Click()
Dim cwhno As String
cwhno = Me.ID
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox, acListBox, acComboBox
ctl.Value = Null
End Select
Next ctl
'rs.edit all the data entered in the form, as any of it could have changed.
Procedures.fill_for_validate ("next"), (cwhno)
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment