simple query and automatic date

How can I store the following query as a variable (the data contorl is datEmployee):

"Select [EmployeeNumber] from EMPLOYEE where [Position] = Customer Assistant"

How do I automatically get the current date in the format dd/mm/yyyy (i.e. 13/11/2003) and assign this to a variable. For example when i click invoice button on a form I want the depature date to be automatically set to the current date.
willgilmoreAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sazhagianambiCommented:
Hi,

dim dat as date
dat=Format(Date(),"dd/mm/yyyy")

After,

Select [EmployeeNumber] from EMPLOYEE where [Position] = Customer Assistant and Date=dat

This Will return the Result For Current Date.

Nambi
0
DocMCommented:
Hy,

strQuery= "Select [EmployeeNumber] from EMPLOYEE where [Position] = Customer Assistant"

strDate = Format(Date, "dd/mm/yyyy")
 
0
hazgodCommented:
the current date command is just date$

so you want to do:

dim thisDeparture as string

thisDeparture = (Select [EmployeeNumber] from EMPLOYEE where [Position] = Customer Assistant) & " " & date$

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Mayank SAssociate Director - Product EngineeringCommented:
You can capture the system date using the Now feautre provided by VB:

Dim current as Date

current = DateValue (CStr(Now))

This will put the system date in dd/mm/yyyy format into the 'current' variable.

You can use:

datEmployee.DatabaseName = "...." ' what-ever
datEmployee.RecordSource = "SELECT * FROM EMPLOYEE.... "
datEmployee.Refresh

With datEmployee.Recordset
  If .EOF Then
    MsgBox "No match found! "
  Else
    .Edit
    ![DepartureDate] = DateValue (CStr(Now))
' I'm assuming that DepartureDate is the name of the attribute
    .Update
  End If
End With


Hope that helps!

Mayank.

0
hazgodCommented:
date$ is the system date function
0
willgilmoreAuthor Commented:
Sorry this doesnt work.

Im trying to get the employee number of datEmployee where employee position = customer assistant. How do I store this result as a variable, accessing the data control. I used the above (EmployeePosition = Select [EmployeeNumber] from EMPLOYEE where [Position] = Customer Assistant) and got this:

Compile error
Syntax error


0
hazgodCommented:
try doing

dim thisEmployeePos

Select [EmployeeNumber] from EMPLOYEE where [Position] = Customer Assistant)

thisEmployeePos= txtEmployeePosition

where does the date come in?
0
willgilmoreAuthor Commented:
Ignore the date at this stage. I have tried the above code before, but it will not work. Do i have to include the datEmployee in the code. If doesnt know where EMPLOYEE table comes from.
0
hazgodCommented:
if the employee position is a number then you will need to do

thisEmployeePos= val(txtEmployeePosition)

to get the number from the text box
0
Mayank SAssociate Director - Product EngineeringCommented:
Try this:

"SELECT * FROM EMPLOYEE WHERE POSITION = 'CUSTOMER ASSISTANT' ; "

' Please notice the quotes around 'customer assistant', and that POSITION is not within bold braces. Also, since you need to modify some date attribute in the recordset, I guess its better to select all attributes (*) rather than simply the Employee Number.

Mayank.
0
Mayank SAssociate Director - Product EngineeringCommented:
Try this:

"SELECT * FROM EMPLOYEE WHERE POSITION = 'CUSTOMER ASSISTANT' ; "

' Please notice the quotes around 'customer assistant', and that POSITION is not within bold braces. Also, since you need to modify some date attribute in the recordset, I guess its better to select all attributes (*) rather than simply the Employee Number.

Mayank.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.