Question

Locked

VBA syntax when querying SQL database

By rjanz59 ·
Tags: Software
I thought I posted this yesterday but can't locate it so I'll try again. I'm trying to insert the first and last time entry date from a SQL table into Word but it fails on the typetext line. I think I need to set a string to the first and last item so I can then use that as the typetext but not sure what the syntax is:
Public Sub TimeDates()
Dim rsFirstDate, rsLastDate As Recordset
Dim strMatterNo, strTimeDate As String

'Get the matter number from the doc
strMatterNo = GetValue("[MatterTIME]")
If Len(strMatterNo) < 1 Then
Exit Sub
End If

'Insert the date of the first unbilled time entry
Selection.GoTo what:=wdGoToBookmark, Name:="FirstTime"

Set rsFirstDate = modOPDB.Query("select min(WORK_DATE) from [JCTRAN] where MATTER_NO ='" & strMatterNo & "' and billed_flag <> 'Y' and billable_flag = 'y'")
Selection.TypeText Format(rsFirstDate, "d MMMM yyyy") & " to "
Set rsLastDate = modOPDB.Query("select max(WORK_DATE) from [JCTRAN] where MATTER_NO ='" & strMatterNo & "' and billed_flag <> 'Y' and billable_flag = 'y'")
Selection.TypeText Format(rsLastDate, "d MMMM yyyy")

End Sub

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Software Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums