Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems! Problems! Help

Status
Not open for further replies.

Maypen

Technical User
Feb 6, 2003
32
GB
Hi, I am new to vb and i am having a few problems. I am creating a language translator. I have succeeded in making this work in a prototype but when i do the same thing in a multiple form project it doesn't work.When i click on a word in the combo box it does not change to the relevant word as in the protype. The data control is pointed to the database and the recordsource is pointed to the language table.The label is pointed the data control and its datafield is pointed to the relevant language, french,spanish etc. Initially the database (Access) could not be found untill i coverted it. Is that the problem? Do i need to do something different for multiple forms?Also, why does the combo box retain old data when the record is changed in the database. Please explain fully as this is new ground for me. Their are 4 forms for 4 languages and you reach each form by a command button from the main page the code is below. Thanks ===================================== Dim db As Database
Dim rs As Recordset

Private Sub Combo1_Click()


Data3.RecordSource = "select * from language where English= '" & Combo1.Text & "'"
Data3.Refresh
End Sub

Private Sub Command2_Click()
Form3.Show
Form1.Hide
End Sub

Private Sub Form_Load()

Set db = DBEngine.OpenDatabase("C:\My Documents\Main Laguage .mdb")
Set rs = db.OpenRecordset("select English from language")

Combo1.Clear

If rs.RecordCount <> 0 Then
Do While Not rs.EOF
Combo1.AddItem rs(&quot;English&quot;)
rs.MoveNext
Loop
End If
db.Close
Set db = Nothing

End Sub

Private Sub Command1_Click()
frmMainTravel.Show
Form1.Hide
End Sub


 
Hi there,

1) &quot; database could not be found until i coverted it&quot;

This is usually because you have the wrong service pack installed, or maybe not any at all. The reason is that VB6 will not see all versions of access, so upgrade this to save converting your database. You can find the service packs here:

2) Do i need to do something different for multiple forms?

If you are calling ojects from one form in another you must prefix the object with the form name so VB knows what form you are referrring to, i.e.

Form1.TextLanguage.text
Form2.TextLanguage.text

same object name different objects.

3) why does the combo box retain old data?

Looking at your code you have the population of the combobox in the formload section, so this is the ONLY time that the combobox is going to get populated. If you are wanting to change the combo box from other events put it in a seperate subroutine so that you can call it from the forrm load and the other sections of your code.

Hope that sheds some light onto things for you.

cheers 'mi casa es su casa'
]-=tty0=-[
ICQ:82621399
 
Thank you for your help tty0. The main problem was my error in pasting the same name for the different forms. I assumed that because it was a different form you could have the same datacontrol and object names. I have another problem but i will start another thread. Thank you again.
 
your welcome :) 'mi casa es su casa'
]-=tty0=-[
ICQ:82621399
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top