distinct query

R

Robert Painter

Hi
i have a table tblemployeeskills with employeeskillid, skillidfk,
employeeidfk.
there are many instances of employeeidfk duplicated. what i would like to
do is find
the unique number of employees with the following code and send it to a
message box, but keep getting error end of statement or syntax problem.. can
anyone see anything wrong it highlights the line mysql = mysql " FROM
tblEmployeeSkills";


Private Sub cmdSearch_Click()
On Error GoTo errhandler:

Dim rs As DAO.Recordset
'/ Create your recordset..

mysql = "SELECT DISTINCT Count(tblEmployeeSkills.EmployeeIDFK) AS
CountOfEmployeeIDFK"
mysql = mysql " FROM tblEmployeeSkills";

Set rs = CurrentDb.OpenRecordset(mysql)
'/ Populate your message boxl..

MsgBox rs!CountOfEmployeeIDFK

'/ Close shop..
rs.close
set rs = nothing

errhandler:
MsgBox "error halted you dimwit"

End Sub


Many thanks for reading and help very much appreciated

Robert
 
G

ghetto_banjo

Missing an ampersand and/or semicolon outside of quotes.

mysql = mysql & " FROM tblEmployeeSkills;"
 
R

Robert Painter

ghetto_banjo said:
Missing an ampersand and/or semicolon outside of quotes.

mysql = mysql & " FROM tblEmployeeSkills;"


Many thanks for that
am now getting error handler in at:

Set rs = CurrentDb.OpenRecordset(mysql)

again any ideas ??
 
R

Robert Painter

Robert Painter said:
am now getting error handler in at:

Set rs = CurrentDb.OpenRecordset(mysql)

again any ideas ??
Please ignore previous post. Have now got it running but it is not giving
distinct result. Have i gone wrong somewhere ??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top