incorrect syntax error using ms access project

mazza

Registered User.
Local time
Today, 08:05
Joined
Feb 9, 2005
Messages
101
Starting to work with MS Access Project and trying to convert an existing database to Access Project.
The old database was based on DAO references, now I am converting to ADO
However I am having a problem with a DCount code that works perfectly in the Normal Access database, but not in Project with the SQL2000 backend

If I run the sub described below I keep getting the error message
Runtime error 170
Line1: incorrect syntax near '#'


the debug points to the first Dcount line
I tried a number of different formats etc but none seems to work.

Any ideas what is going on here?


Private Sub Schedule_Click()
Dim strInput As Date
Dim strMsg As String
Dim test As Date
Dim testdate As Date
Dim testdate2 As Date

Beep
strMsg = "To avoid incorrect sequencing of the planning schedule please enter the first date of the month that you want to add to the schedule." & vbCrLf & vbLf & "Please enter the daye as follows DD/MM/YY."
strInput = InputBox(Prompt:=strMsg, Title:="Add new budgeted slots to the planner")


If DCount("slotdate", "TblSlotFrame1", "slotdate = #" & Format(strInput, "mm\/dd\/yyyy") & "#") > 0 Then
Displaymessage "The slots for this period starting '" & strInput & "' have already been created. Please check your entry."
Exit Sub
Else
If DCount("slotdate", "TblSlotFrame1", "slotdate = #" & Format(strInput, "mm\/dd\/yyyy") & "# - 1") > 0 Then
createnewslotdates

Else
Displaymessage "The system cannot find an entry for the previous period before '" & strInput & "'." & vbCrLf & vbCrLf & "Please select the previous month on the budget page and create the slots for that period first."
End If
End If



End Sub
 
Open any VBA (form VBA, or Module).
Click on TOOLS, REFERENCES, deselect all MISSING references, and try again.
 
I got the following references . am i missing some?
Visual basics for applications
Microsoft access 11.0 object library
OLE Automation
Microsoft ActiveX Data objects 2.1 Library
Microsoft ADO Ext 2.8 for DLL and security

switched all of and on again but still same error
 
got the solution in the end

it seems that using ADO / access project doesn't require the # syntax
#" & Format(strInput, "mm\/dd\/yyyy") & "#

but instead use ' to turn the date into a string
'" & Format(strInput, "mm\/dd\/yyyy") & "'
 

Users who are viewing this thread

Back
Top Bottom