473,388 Members | 1,385 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,388 software developers and data experts.

Can I change the following code?

Hi everybody, I want to retrieve the details from the database by the date from (MM/DD/YYYY) to (MM/DD/YYYY). For that I have to change the following code as follows
Expand|Select|Wrap|Line Numbers
  1. rs.Open "select * from Table where empid='" & Text1.Text & "'", con
So kindly anyone reply me.
Feb 2 '07 #1
11 1600
Killer42
8,435 Expert 8TB
Hi everybody, I want to retrieve the details from the database by the date from (MM/DD/YYYY) to (MM/DD/YYYY). For that I have to change the following code as follows
rs.Open "select * from Table where empid='" & Text1.Text & "'", con
Do you need to do this instead of the empid, or the two together? Here are some ideas...
  • Just the date range
    Expand|Select|Wrap|Line Numbers
    1. rs.Open "select * from Table where DateField Between #" & _
    2.         strStartDate & "# AND #" & strEndDate & "#", con
  • Both
    Expand|Select|Wrap|Line Numbers
    1. rs.Open "select * from Table where empid = '" & Text1.Text & _
    2.         "' AND DateField Between #" & strStartDate & "# AND #" & _
    3.         strEndDate & "#", con
I'm assuming here that your dates are in string variables, already formatted as MM/DD/YYYY.
Feb 2 '07 #2
willakawill
1,646 1GB
And you are assuming it is an Access database
Feb 2 '07 #3
Killer42
8,435 Expert 8TB
And you are assuming it is an Access database
Guilty.

I do tend to think in terms of VB6 and Access, and if people aren't specific, I figure they'll just have to make do with what they get. :)
Feb 2 '07 #4
Do you need to do this instead of the empid, or the two together? Here are some ideas...
  • Just the date range
    Expand|Select|Wrap|Line Numbers
    1. rs.Open "select * from Table where DateField Between #" & _
    2.         strStartDate & "# AND #" & strEndDate & "#", con
  • Both
    Expand|Select|Wrap|Line Numbers
    1. rs.Open "select * from Table where empid = '" & Text1.Text & _
    2.         "' AND DateField Between #" & strStartDate & "# AND #" & _
    3.         strEndDate & "#", con
I'm assuming here that your dates are in string variables, already formatted as MM/DD/YYYY.
I tried with that codigs.But run time error has occured as "Too few parameters required".So kindly give me the suggestion for that.
Feb 5 '07 #5
i thing there is no error in the above query

replace the code with this one
Expand|Select|Wrap|Line Numbers
  1. rs.Open "select * from Table where empid = '" & Text1.Text & _
  2.         "' AND DateField Between #" & strStartDate & "# AND #" & _
  3.         strEndDate & "#", con,adOpenForwardOnly ,adLockReadOnly
Feb 5 '07 #6
i thing there is no error in the above query

replace the code with this one
Expand|Select|Wrap|Line Numbers
  1. rs.Open "select * from Table where empid = '" & Text1.Text & _
  2.         "' AND DateField Between #" & strStartDate & "# AND #" & _
  3.         strEndDate & "#", con,adOpenForwardOnly ,adLockReadOnly
I used two text boxes to get the date from the MonthView control.
So i have written the code is
Expand|Select|Wrap|Line Numbers
  1. rs.Open "select * from tbl where empid = '" & Text1.Text & "' AND DateField Between #" & Text2.Text & "# AND #" & Text3.Text & "#", con, adOpenForwardOnly, adLockReadOnly
Eventhough the same error has occured.So kindly reply me
Feb 5 '07 #7
Killer42
8,435 Expert 8TB
It may be that you have not adjusted our field names to match your own. For example, I used the name DateField because I don't know what yours is called. If your field name is not DateField then you will need to change this.

If that's not the problem, we'll have to investigate further.

Note, if you're going to post an error message, make sure you copy it precisely. I suspect that "Too few parameters required" is not quite the wording Access used (though as always, I could be wrong).
Feb 5 '07 #8
It may be that you have not adjusted our field names to match your own. For example, I used the name DateField because I don't know what yours is called. If your field name is not DateField then you will need to change this.

If that's not the problem, we'll have to investigate further.

Note, if you're going to post an error message, make sure you copy it precisely. I suspect that "Too few parameters required" is not quite the wording Access used (though as always, I could be wrong).

I have written the following code to retrieve and display the details into the ListView control.
Expand|Select|Wrap|Line Numbers
  1. rs3.Open "select * from tbl where empid = '" & Text1.Text & "' AND dat Between #" & Text2.Text & "# AND #" & Text3.Text & "#", con, adOpenForwardOnly, adLockReadOnly
  2. rs.MoveFirst
  3. Do Until rs.EOF
  4.    j = j + 1
  5.    lv.ListItems.Add j, , j
  6.    lv.ListItems(j).SubItems(1) = rs!empid
  7.    lv.ListItems(j).SubItems(2) = rs1!firstname & rs1!lastname
  8.    lv.ListItems(j).SubItems(3) = rs3!dat
  9.    lv.ListItems(j).SubItems(4) = rs3!intime
  10.    lv.ListItems(j).SubItems(5) = rs3!outtime   
  11.    rs.MoveNext
  12. Loop
But I couldnt retrieve all the details from the database table.
I could retrieve only the same data repeatedly until the EOF.For that how can I retrieve the full details from the table.So kindly reply me
Feb 6 '07 #9
willakawill
1,646 1GB
When you are posting code please use code tags. Clearly you are highlighting your code and clicking on the center justify and bold buttons. Please don't do that. Click on the '#' button instead. This is the third time I have added code tags to your posts
Thanks
Feb 6 '07 #10
When you are posting code please use code tags. Clearly you are highlighting your code and clicking on the center justify and bold buttons. Please don't do that. Click on the '#' button instead. This is the third time I have added code tags to your posts
Thanks
ok thanks.
I got the solution for that.
Feb 6 '07 #11
When you are posting code please use code tags. Clearly you are highlighting your code and clicking on the center justify and bold buttons. Please don't do that. Click on the '#' button instead. This is the third time I have added code tags to your posts
Thanks
I can retrieve all the details from the table by using the following code.
Expand|Select|Wrap|Line Numbers
  1. rs3.Open "select * from tbl where empid = '" & Text1.Text & "' AND dat Between #" & Text2.Text & "# AND #" & Text3.Text & "#", con, adOpenForwardOnly, adLockReadOnly
  2. rs3.MoveFirst
  3. Do Until rs3.EOF
  4. j = j + 1
  5. lv.ListItems.Add j, , j
  6. lv.ListItems(j).SubItems(1) = rs!empid
  7. lv.ListItems(j).SubItems(2) = rs1!firstname & rs1!lastname
  8. lv.ListItems(j).SubItems(3) = rs3!dat
  9. lv.ListItems(j).SubItems(4) = rs3!intime
  10. lv.ListItems(j).SubItems(5) = rs3!outtime
  11. rs3.MoveNext
  12. Loop
But Now I want take the printout of what are the date listed inside the ListView control by clicking one command button.So kindly give me the suggestion for that.
Feb 6 '07 #12

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

Similar topics

4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
4
by: pjac | last post by:
I need some help with some VB language that will change the screen resolution on a monitor when a MS-Access 2000 database is opened from 1024 x 768 to 800 x 600. Any help with this effort would be...
2
by: Smith Duggan | last post by:
I am attempting to change the background properties of a rectangle in the code, and have been stuck now for a day and a half. This is my first access app. Please be gentle with my steaming pile...
8
by: lauren quantrell | last post by:
Is there a way to force a change in a user's screen resolution using VBA code without having any input from the user? Example: User John Backwards has his screen set to 800 x 600 pixels. Backwards...
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
6
by: Alpha | last post by:
I have several textboxes that I need to chang the text when the selection row is changed in a datagrid. I have the following code. This textbox displayes the initial selection but when I click on...
2
by: Sanjeeva Reddy | last post by:
hai Anti Keskinen, i have used the following code MyListView->LargeImageList->ImageSize = gcnew System::Drawing::Size(100, 100); // Sets large image size to 100, 100 here i am getting error...
3
by: Tom | last post by:
I am writing a Visual basic .Net database application. There are many forms that first let you select and look at a DB record and then when you click a "modify" button you are allowed to change...
7
by: Martin Pritchard | last post by:
Hi, Sorry for my ignorance, but I'm a bit new to C++. I've been handed over a C++ app written in VS2002 which I have to convert to VS2005. Apparently it's been written in a C style, but cannot...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.