| View previous topic :: View next topic |
| Author |
Message |
dark_syde Newbie
Joined: 04 Feb 2004 Posts: 20 Location: Uk : Hemel Hempstead
|
Posted: Feb 4th, 2004 06:47 PM Post subject: Data Transfer |
|
|
Hello everyone, interesting site.
I know that im new to vb6 but I know whn I need help, thats why im here.
What I would like help with and I have almost no idea how to do it, is to list certain fields from a database into a text box.
Database : Job Information.mdb
Table: Job Information
Concentrated Fields: Customer & Reminder
What I would like happen is that on a form load event, some code runs that searches my database Job Information.mdb , searches the table Job Information and looks in the field Reminder which holds a date and checks to see if it matches the days date (Todays date.)
If the date in the field Reminder matches Todays date then the contents in field Customer] is added to the Listbox.
Could someone spare a few moments to help me out please?
Thankyou |
|
| Back to top |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
|
| Back to top |
|
dark_syde Newbie
Joined: 04 Feb 2004 Posts: 20 Location: Uk : Hemel Hempstead
|
Posted: Feb 7th, 2004 06:46 AM Post subject: |
|
|
Thankyou Avis for the working example and the quick reply. Ive been trying to tweek it a bit by adding
| Code: | | Combo2.AddItem RS("Number") |
again to see wether I can add the contents of combo2 into the text box but ist working yet.
The part where it says
| Code: | | SQL = "SELECT * FROM MyDB WHERE ID = " & Combo1.Text |
Ive been trying to change the & Combo1.Text to Date, Today() & even Now so it fetches Todays date so I wont need a combo box.
Is there a way I can use Today's date to display the text in my chosen column instead of having a combo box.
EX: Today : 07/02/2004 so it picks the record(s) that have this date in and displays them inside the multi line text box.
Thankyou again |
|
| Back to top |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
|
| Back to top |
|
dark_syde Newbie
Joined: 04 Feb 2004 Posts: 20 Location: Uk : Hemel Hempstead
|
Posted: Feb 7th, 2004 02:18 PM Post subject: |
|
|
Sorry about that. I was looking at the code and it lists all the Dates in the Date field in the MS Acess Database when it runs.
I was trying to use the following code so that it will only show the records that have the reminder date of today:
| Code: | Do Until RS.EOF = True
If RS("Date") = Date Then
List1.AddItem
RS.MoveNext
Loop
End If
|
It tells me 'Argument not optional' then highlights the List1.AddItem. |
|
| Back to top |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
|
| Back to top |
|
dark_syde Newbie
Joined: 04 Feb 2004 Posts: 20 Location: Uk : Hemel Hempstead
|
Posted: Feb 8th, 2004 03:14 PM Post subject: |
|
|
OK ive got that. I wanted to filter the contents of the listbox depending if the date in Reminder matches the date on the computer (todays date)
I was using the following code but have no success so far:
| Code: | If RS("Reminder") = Date Then
Do Until RS.EOF = True
lstCustomers.AddItem RS("Customer")
RS.MoveNext
Loop
End If |
So as each day goes by, ifferent customer names are listed in the listbox.
Only problem is, my If statement seems ok to me but when run, nothing appears in the listbox.
Do i need to format the date or something? |
|
| Back to top |
|
Andir Centurion

Joined: 21 Dec 2003 Posts: 184 Location: Chicago Area
|
Posted: Feb 9th, 2004 12:31 AM Post subject: |
|
|
It may be mis-interpreting the date. One way to check this is to do a
Debug.Print RS("Reminder"), Date
Compare these by eye to see if they are the same in the immediate window.
Try changing to CDate(RS("Reminder")) or defining the format using:
If Format(Date, "MM-DD-YYYY") = Format(RS("Reminder"), "MM-DD-YYYY") Then
to see if it evalutates that way. _________________ If you happen to see little people sitting on your desk...don't tell anyone or they might think your crazy too. |
|
| Back to top |
|
|