M
MikeS
I am developing an application that will manage a database which will be used
for building an organization chart. On my data entry form I have a Delete
button for what else?....deleting unwanted or former employees. However, one
of the crteria for allowing this delete is to insure that it will not leave
any orphans. In other words, if Bob Jones reports to John Smith and John
Smith gets deleted, Bob Jones becomes an orphan.
Now with that said, I have tried to use the DCount function to search the
database to see if that person's "Name" show's up in the "ReportsTo" column.
Here is the code:
Dim intOrphan As Integer, strName As String
strName = Me.txtName.Value
intOrphan = DCount("*", "dbrgData", "[ReportsTo] =" & strName)
If I insert the person's actual name such as:
intOrphan = DCount("*", "dbrgData", "[ReportsTo] = 'John Smith'")
it will work fine, however, using the varialbe "strName", I get the
following error:
Syntax error (missing operator) in query expression '[ReportsTo] =John
Smith'.
It interprets the value of the variable "strName" (which is John Smith) but
it will not use it to query the database.
Can anyone tell me what is going on here?
Thanks,
Mike
for building an organization chart. On my data entry form I have a Delete
button for what else?....deleting unwanted or former employees. However, one
of the crteria for allowing this delete is to insure that it will not leave
any orphans. In other words, if Bob Jones reports to John Smith and John
Smith gets deleted, Bob Jones becomes an orphan.
Now with that said, I have tried to use the DCount function to search the
database to see if that person's "Name" show's up in the "ReportsTo" column.
Here is the code:
Dim intOrphan As Integer, strName As String
strName = Me.txtName.Value
intOrphan = DCount("*", "dbrgData", "[ReportsTo] =" & strName)
If I insert the person's actual name such as:
intOrphan = DCount("*", "dbrgData", "[ReportsTo] = 'John Smith'")
it will work fine, however, using the varialbe "strName", I get the
following error:
Syntax error (missing operator) in query expression '[ReportsTo] =John
Smith'.
It interprets the value of the variable "strName" (which is John Smith) but
it will not use it to query the database.
Can anyone tell me what is going on here?
Thanks,
Mike