473,404 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

VB 2005 MS Access Time question

I am a newb on VB 2005 and I am trying to rework a DB app an ex colleague had made before.

There is an ACCESS backend with a field tstmp (Timestamps) I need to make a simple query with two Textboxes and the Text Boxes take the users input in the MM/DD/YYYY hh/mm/ss format.

The code I have is :

Dim Dt as datetime
Dim Dt1 as datetime

dt = TextBox1.Text
dt1 = TextBox2.Text


"select * from table1 where tstmp between '" & dt & "' and'" & dt2 & "'

this query generates an error. Could anyone please help ?
Jun 1 '07 #1
4 1573
Dököll
2,364 Expert 2GB
I am a newb on VB 2005 and I am trying to rework a DB app an ex colleague had made before.

There is an ACCESS backend with a field tstmp (Timestamps) I need to make a simple query with two Textboxes and the Text Boxes take the users input in the MM/DD/YYYY hh/mm/ss format.

The code I have is :

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim Dt as datetime
  3. Dim Dt1 as datetime
  4.  
  5.  dt = TextBox1.Text
  6. dt1 = TextBox2.Text
  7.  
  8.  
  9. "select * from table1 where tstmp between  '" & dt & "'  and'" & dt2 & "'
  10.  
  11.  
this query generates an error. Could anyone please help ?
What is the error you are getting, abhisdoc!

It looks like you are not telling VB Express the database name, though you did tell it the table name...
Jun 2 '07 #2
Hello,

Thank you so much for helping me out. The database is connecting to the frontend because it is giving a report, just its not perfect, for example if I search for times between 6:00 PM and 9:00 PM, I may get something but I wont get something in a different time. I am thinking it is a problem in my query. I will post the query again...

dim dt as string
dim dt2 as string

dt = TextBox1.Text
dt2 = TextBox2.Text

res.Open("select distinct wccode, ldno from ccui where tstmp between CONVERT(DateTime,'" & dt & "') and CONVERT(DateTime,'" & dt2 & "')", con, 1, 2)

res.MoveFirst()

The error I am getting is EOF or BOF = True. Con is the active connection and it works as I have been able to retrieve data using the same connection but a different query.

The DB is Access 2007 and the field tstmp is storing the time stamps. Also the tstmp field is set as memo, I tried to set it as datetime it still didnt help. Am I querying right ?

Regards
Abhijit
Jun 4 '07 #3
Denburt
1,356 Expert 1GB
Hello,

Thank you so much for helping me out. The database is connecting to the frontend because it is giving a report, just its not perfect, for example if I search for times between 6:00 PM and 9:00 PM, I may get something but I wont get something in a different time. I am thinking it is a problem in my query. I will post the query again...

dim dt as string
dim dt2 as string

dt = TextBox1.Text
dt2 = TextBox2.Text

res.Open("select distinct wccode, ldno from ccui where tstmp between CONVERT(DateTime,'" & dt & "') and CONVERT(DateTime,'" & dt2 & "')", con, 1, 2)

res.MoveFirst()

The error I am getting is EOF or BOF = True. Con is the active connection and it works as I have been able to retrieve data using the same connection but a different query.

The DB is Access 2007 and the field tstmp is storing the time stamps. Also the tstmp field is set as memo, I tried to set it as datetime it still didnt help. Am I querying right ?

Regards
Abhijit


I see errors in both posts...

If the field in the table is a Date/Time then the query above should work with a few tweaks, due to the positioning of your quotes.
Expand|Select|Wrap|Line Numbers
  1.  res.Open("select distinct wccode, ldno from ccui where tstmp between CONVERT(DateTime,'" & dt & "') and CONVERT(DateTime,'" & dt2 & "')", con, 1, 2) 
However if your field is a Memo field (strange but O.K.) Then I would use the query from the other post, with the following corrections. Although make sure the declared variables coincide with the variables in the query string.

Expand|Select|Wrap|Line Numbers
  1.  res.Open("select * from table1 where tstmp between '" & dt & "' and '" & dt2 & "'", con, 1, 2)
Jun 4 '07 #4
I'm having a silimar problem to this one above that you solved.

The error I'm getting is "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."

Here is my query.

Expand|Select|Wrap|Line Numbers
  1. "SELECT * from table WHERE entereddate BETWEEN CONVERT (DateTime, ' "& startDate &" ') AND CONVERT(DateTime, ' "& endDate &" ') "
startDate and endDate are my variables, but i've even tried hard coding dates in just to get the query working.

entereddate is added by an ASP page with the DateAdd ("h", 2, now())) to an access DB 2003 and the column has the "Date/Time" data type with General Date as the Format.

Am I not able to pull this because of the hh:mm:ss aspect? I tried using access to see if I can pull something like this and it works with the SQL that access rights. Example:
Expand|Select|Wrap|Line Numbers
  1. SELECT entereddate
  2. FROM table
  3. WHERE (((ib_amps_project.entereddate) Between #6/4/2007# And #6/10/2007#));
Jun 13 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: sathyashrayan | last post by:
Following are the selected thread from the date:30-jan-2005 to 31-jan-2005. I did not use any name because of the subject is important. You can get the original thread by typing the subject...
2
by: raylopez99 | last post by:
I am trying to program a database from inside C++.NET via Visual Studio 2005 using the ADO.NET set of classes, but this I believe is a SQL Server 2005 Express permissions question under Windows XP...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.