Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting

Post new topic   Reply to topic
Data Transfer
View previous topic :: View next topic  
Author Message
dark_syde
Newbie


Joined: 04 Feb 2004
Posts: 20
Location: Uk : Hemel Hempstead

PostPosted: Feb 4th, 2004 06:47 PM    Post subject: Data Transfer Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Feb 5th, 2004 02:32 AM    Post subject: Reply with quote

Hi!

Check this attachment!
http://www.avissoft.com/attachment.php?postid=839

This sample app. gets the stuff from database and loads it into a combobox. Almost the same thing you need.

Though it does not gets the date stuff. But try this if you don't understand then post here again and we'll be more than happy to help you out.

The code is fairly easy to understand. Once you open the project you'll understand it.

Thanks!
_________________
Code Snippets, Tutorials, Utilities, Controls

Low cost Web Hosting
Hosting starts at as low as $4 per year!


Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
dark_syde
Newbie


Joined: 04 Feb 2004
Posts: 20
Location: Uk : Hemel Hempstead

PostPosted: Feb 7th, 2004 06:46 AM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Feb 7th, 2004 01:23 PM    Post subject: Reply with quote

Hi!

So let me get you ...you want to have today's date instead on the combo1.text ? right ?

if yes then just do this:

Code:
SQL = "SELECT * FROM MyDB WHERE Reminder = " & Date


I hope this helps! Is this isn't what you want then just clear what you are trying to do again!

Thanks!
_________________
Code Snippets, Tutorials, Utilities, Controls

Low cost Web Hosting
Hosting starts at as low as $4 per year!


Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
dark_syde
Newbie


Joined: 04 Feb 2004
Posts: 20
Location: Uk : Hemel Hempstead

PostPosted: Feb 7th, 2004 02:18 PM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Feb 8th, 2004 05:15 AM    Post subject: Reply with quote

Hi!

You're not writing what to add to the List...

Code:
List1.AddItem RS("Something")


Now just replace the Something in the RS and that will be added to the listbox.

Thanks!
_________________
Code Snippets, Tutorials, Utilities, Controls

Low cost Web Hosting
Hosting starts at as low as $4 per year!


Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
dark_syde
Newbie


Joined: 04 Feb 2004
Posts: 20
Location: Uk : Hemel Hempstead

PostPosted: Feb 8th, 2004 03:14 PM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
Andir
Centurion


Joined: 21 Dec 2003
Posts: 184
Location: Chicago Area

PostPosted: Feb 9th, 2004 12:31 AM    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic