Hi Guys,
I have 5 subforms that run off 5 separate queries that are filtered by the criteria pointing to each day of the week. I have put together the following but it updates the 'ptemp' in each record with the last value it calculated, i.e. the correct value for the last record. Obviously i'm looking for each record to be dealt with on its own.
This is my first go at putting together a loop from scratch. Any ideas?
I have 5 subforms that run off 5 separate queries that are filtered by the criteria pointing to each day of the week. I have put together the following but it updates the 'ptemp' in each record with the last value it calculated, i.e. the correct value for the last record. Obviously i'm looking for each record to be dealt with on its own.
This is my first go at putting together a loop from scratch. Any ideas?
Code:
Private Sub Nearby_Click()
Dim postcode1 As String
Dim postcode2 As String
Dim sHold As String
Dim strSQL As String
Dim Rst As DAO.Recordset
Dim db As DAO.Database
'On Error GoTo Errorskip
postcode1 = Me.postcode1.Value
strSQL = "SELECT * FROM qryDate"
Set Rst = CurrentDb.OpenRecordset(strSQL)
Rst.MoveFirst
Rst.MoveLast
Do While Not Rst.EOF
If Rst.RecordCount = 0 Then
Exit Sub
Else
postcode2 = Rst![Postcode]
sHold = PostcodeSearch(postcode1, postcode2)
Forms![frmCalendar]![Date]![ptemp] = Mid(sHold, InStr(sHold, "|") + 1)
End If
Rst.MoveNext
Loop
Rst.Close
db.Close
'Errorskip:
' Resume Next
End Sub