I have a form "frmWeightReduction". From that form I am opening another form "frmDietExercise". I have written the following SQL statement. Upon opening the "frmDietExercise" the records are in random order and not as in the SQL statement. I am a rookie. Any help would be appreciated. Here is the code:
Dim cd As DAO.Database
Dim rs As DAO.Recordset
Dim strPID As String
Dim SQL As String
Dim strLinkCriteria
If Me.Dirty = True Then
Me.Dirty = False
End If
Mglobal.gReturnToG = "WR"
Mglobal.gInsertNewRec = False
Mglobal.gReview = True
Set cd = CurrentDb
SQL = "SELECT PI.*, DE.* FROM tblPatientInformation PI, tblDietExercise DE " & _
"WHERE PI.PatientID = '" & Me.tbPatientID.Value & "' " & _
"ORDER BY DE.DietExerciseID"
Set rs = cd.OpenRecordset(SQL)
strPID = Me.tbPatientID.Value
strLinkCriteria = "[PatientID] = '" & strPID & "'"
DoCmd.OpenForm "frmDietExercise", , , strLinkCriteria
rs.Close
Set rs = Nothing
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, "frmWeightReduction", acSaveYes
Dim cd As DAO.Database
Dim rs As DAO.Recordset
Dim strPID As String
Dim SQL As String
Dim strLinkCriteria
If Me.Dirty = True Then
Me.Dirty = False
End If
Mglobal.gReturnToG = "WR"
Mglobal.gInsertNewRec = False
Mglobal.gReview = True
Set cd = CurrentDb
SQL = "SELECT PI.*, DE.* FROM tblPatientInformation PI, tblDietExercise DE " & _
"WHERE PI.PatientID = '" & Me.tbPatientID.Value & "' " & _
"ORDER BY DE.DietExerciseID"
Set rs = cd.OpenRecordset(SQL)
strPID = Me.tbPatientID.Value
strLinkCriteria = "[PatientID] = '" & strPID & "'"
DoCmd.OpenForm "frmDietExercise", , , strLinkCriteria
rs.Close
Set rs = Nothing
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, "frmWeightReduction", acSaveYes