0

This is my query which runs perfectly

"SELECT RemBal FROM Sales WHERE CustomerName='" & CustomerName.Text & "'"

now i am trying to get the balance on two basis customer name & current date

"SELECT RemBal FROM Sales WHERE CustomerName='" & CustomerName.Text & "' AND SaleDate=#" & SaleDate.Value & "#"

now this query not giving me any error but not returning any value too please help

6
  • i am trying to get the records from MS-ACCESS in vb6 code Commented Jan 2, 2014 at 5:07
  • if u are asking about date format then 02-01-2014 its a date picker Commented Jan 2, 2014 at 5:10
  • 1
    Try putting the date in a format of yyyy-mm-dd. I have had success with this access using this format in the past Commented Jan 2, 2014 at 5:10
  • if i use '" & & "' its giving me error... data type mismatch Commented Jan 2, 2014 at 5:12
  • 1
    using yyyy-mm-dd did solved the problem... MS-ACCESS database always needs some odd things Commented Jan 2, 2014 at 5:16

2 Answers 2

1

Try this

SaleDate.Format = DateTimePickerFormat.Custom
SaleDate.CustomFormat = "yyyy-mm-dd"

"SELECT RemBal FROM Sales WHERE CustomerName='" & CustomerName.Text & "' AND SaleDate=#" & SaleDate.Text()  &"# "
Sign up to request clarification or add additional context in comments.

Comments

0
SELECT rembal 
FROM   sales 
WHERE  customername = '" & CustomerName.Text & "' 
       AND Format(saledate, 'dd/MM/yyyy') = '" & SaleDate.Value & "' 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.