speakers_86
Registered User.
- Local time
- Today, 05:16
- Joined
- May 17, 2007
- Messages
- 1,919
I don't usually find a need to deal with recordsets, so I usually struggle. I've got a datasheet subform and I want to force the date that is displayed to have the leading 0 if required in the time.
edit - seems like there is an issue with my query.
edit - I fixed the query, and the issue is still there.
edit - is the variable in my query not getting passed correctly?
This is in the query. frmSettings is open.
edit - I'm makng some progress. The variable is not being passed. I removed the criteria from the query and the loop suddenly works. On the other hand, every record had the same value for me.TodaysDate. So the variable is not being passed, and there is something wrong with my loop.
Code:
Private Sub Form_Current()
Dim DB As Database
Dim RST As Recordset
Dim D As String
Dim T As String
Set DB = CurrentDb
Set RST = DB.OpenRecordset("qryMSL") 'Too few variables error here
If Not RST.EOF Then RST.MoveFirst
Do While Not RST.EOF
D = Format([CurrentDate], "mm/dd/yyyy")
T = Format([CurrentTime], "hhnn")
If Len(T) = 3 Then
Me.TodaysDate = D & " 0" & T
Else
Me.TodaysDate = D & " " & T
End If
RST.MoveNext
Loop
RST.Close
End Sub
edit - seems like there is an issue with my query.
edit - I fixed the query, and the issue is still there.
edit - is the variable in my query not getting passed correctly?
Code:
Like Format(DateAdd("h",[forms]![frmSettings].[TimeZoneAdjustment],Now()),"mm/dd/yyyy") & "*"
This is in the query. frmSettings is open.
edit - I'm makng some progress. The variable is not being passed. I removed the criteria from the query and the loop suddenly works. On the other hand, every record had the same value for me.TodaysDate. So the variable is not being passed, and there is something wrong with my loop.
Last edited: