• Congratulations to the Class of 2024 on your results!
    Let us know how you went here
    Got a question about your uni preferences? Ask us here

VB6 Problem...URGENT!!! (1 Viewer)

dis_armer

New Member
Joined
Jul 20, 2003
Messages
14
Can any body help.....
for my sdd major, ive got a program that allows a user to book an airline flight, very similar to one that you would use for booking flights over the net.

problem is, i have a separate database with a list of flights, departure dates and stuff, and in my program i have a number of combo boxs which the user chooses what day they want to leave where from and to. i want those selections from the combo box to be the search criteria for the database so that i can match flights from the database and display them on the program, but i dont know how.

Can anybody help???
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
Have a look at this thread several threads down..

Its the same database searching thing. It should give you plenty of ideas on how to do it.
 

del

Member
Joined
Jul 8, 2002
Messages
412
Gender
Undisclosed
HSC
N/A
what you do is determine which item in the combo box is selected using the Text property (eg cboMyCombo.Text) this will return the text value of the selected item.

Then using the values, formulate your sql query.

but yeah check that thread out.... pretty much has everything else needed
 

dis_armer

New Member
Joined
Jul 20, 2003
Messages
14
ok,
thanks for the replies, i need as much help as possible. i went back to that thread on searchs and used the code posted up by sunny.

now when i run the program im getting and error msg saying
runtime error 3343
unrecognised database format (followed by the path of the database im using)

whats happening?
 
Last edited:

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
Some more details will be helpful.

What format database are you using?
What DBMS have you got installed?
What method are you using to access the database?
 

dis_armer

New Member
Joined
Jul 20, 2003
Messages
14
dbms = ms access 2000
i dunno what format or method, i think DAO if thats what you mean, im only going off the code and msgs you guys posted up in that thread
 

dis_armer

New Member
Joined
Jul 20, 2003
Messages
14
so i need vb6 service pack 4 to fix my problem and continue. lol, thats gonna take 4hrs on my slow dial up modem.

im in a bita trouble now!
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
Which DAO version are you referencing and which SP of VB6 do you have?

There might be a workaround without downloading SP4.
 

dis_armer

New Member
Joined
Jul 20, 2003
Messages
14
im now d/l sp 4, and i dont know what i have now. im referencing DAO 3.6 object library
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
Try this and see if it works for you

1) Open the database you made in Access 2000.
2) go Tools => Database Utilities => Convert Database => To Prior Access Database Version (the other option should be greyed out if the database was made with Access 2000).
3) You'll get a dialog to save the new converted database. Save it with a different filename.

Now try the code again with the newly converted database. Note that this database is now in an older format. You'll be able to view the contents of the database in Access, but you won't be able to change things.
 

dis_armer

New Member
Joined
Jul 20, 2003
Messages
14
ok, ok.
before i posted the reply up where i said what referencing i was using i hadnt actually changed it to DAO 3.6. now i have and that seems to have solved the problem because it now runs through where before it didnt.

im now going to have to play around in order to get my search results into the right labels. thanks for the help. it is greatly appreciated!
 

dis_armer

New Member
Joined
Jul 20, 2003
Messages
14
ok so ive applied the little testBD example to my project and it worked (well it kept displaying a No Match msgbox any way), but i cant apply it to do what i want.

i have a number of combo boxs in form 1. i want the user to select their departure city and date and then those will be the criteria for the DB search. then i want the matching airline flight feilds from the DB to be displayed in labels in form 2.
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
The sample program shows you how you can go about doing simple queries to search the sample database.

Try and adapt it using del's suggestions from before to suit your program.
 

dis_armer

New Member
Joined
Jul 20, 2003
Messages
14
im trying to, but im not getting anywhere. i dont know what to do with dels suggestion, i dont know where to put cboMyCombo.text into my program. (I know that you have to change the name from mycombo, so thats not the problem)

could somebody please possibly run me through this step by step so that i fully understand what it is i have to do, so that way i can understand how it works and that way i will be able to sort it out on my own?
 
Last edited:

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
Say you have two comboboxes, cmb1 and cmb2 that you want to be the search criteria.

Using the SQL info from the other threads, your final search query might look something like:

Code:
sql = "SELECT * FROM tablename WHERE column1='" & cmb1.Text & "' AND column2='" & cmb2.Text & "'"
Its hard for us to run you through things step by step without having seen your project at all.....the best we can do it poke you in a general direction.
 

dis_armer

New Member
Joined
Jul 20, 2003
Messages
14
yep im kinda catching on.
im getting an error
variable not defined

variable being SQL
 
Last edited:

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
If you have Option Explicit somewhere, you need to declare your variables before you can use them. ie, you need to declare the variable sql before you can use it.

sql might've been a bad name to use - it could be some keyword. Just try something else like sqlQuery.
 

dis_armer

New Member
Joined
Jul 20, 2003
Messages
14
ok so i have to declare it, but declare it as what, thats what i dont understand....this suxs so much, why cant things just be simple....lol!
 

Fosweb

I could be your Doctor...
Joined
Jun 20, 2003
Messages
594
Location
UNSW. Still.
Gender
Male
HSC
2003
OK:

doing just this:

SQLQuery = "SELECT * FROM flights WHERE from ='" & cityfrom.Text & "' and to = '" & cityto.Text & "'"

is NOT searching the database. Sure, you have set your SQLQuery up as a string, containing the values from these two combo boxes, but at the moment, you are not DOING anything with this SQLQuery.

SO: What an SQL Query actually does is OPEN A RECORDSET from a database, with certain criteria as specified in the query you send to the database.
You send this query to the database by:

set RS = DB.OpenRecordset(SQLQuery)

That is the bit that actually uses the sql query to return you a recordset with your results.

Your project doesnt like me. It couldnt find your module, and so wouldnt run properly. But you should be able to get the idea from this post, and by reading the other posts in the thread sunny is referring to... there is a lot of database info there...

Have fun... Also: fix up so that I cant accidently book myself going from Sydney to Sydney or at the same time of day, etc...
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top