I'm using a list box lstClients to add people to a subform whose source is an unsorted query qryTempRegular
Its AfterUpdate procedure below appends the ClientID from the list box along with values for Activity, ActivityDate and Hours from fields in the main form.
The subform always sorts itself by ClientName, which qryTempRegular retrieves via the ClientID.
I can't find anything that causes this sorting and need to remove it. Ideas?
Code:
Private Sub lstClients_AfterUpdate()
On Error GoTo Err_Q
'Check Date and Duration have been entered
If IsNull(Me.ActivityDate) Or Me.ActivityDate = "" Or IsNull(Nz(Me.Hours)) Or Me.Hours = "" Then
MsgBox ("Add Date and Hours")
Exit Sub
End If
'Temporarily prevent warnings
DoCmd.SetWarnings False
'Add new records to tblTempRegular and show in subform
Dim sqlTxt As String
Dim item As Variant
sqlTxt = "INSERT INTO tblTempRegular(Activity,ClientID,ActivityDate,Hours,ActivityID) Values(" _
& Chr(34) & Me.cboActivity.Value & Chr(34) & ", " _
& Chr(34) & Me.lstClients.Value & Chr(34) & ", " _
& Chr(34) & Me.ActivityDate & Chr(34) & ", " _
& Chr(34) & Me.Hours & Chr(34) & ", " _
& Chr(34) & Me.ActivityID & Chr(34) & ")"
DoCmd.RunSQL (sqlTxt)
'Recalculate so the client selected in list box appears in subform
Me.Recalc
'Turn warnings back on
DoCmd.SetWarnings True
Exit_Q:
Exit Sub
Err_Q:
MsgBox Err.Description
Resume Exit_Q
End Sub