PDA

View Full Version : Sleeper: Excel and mysql



jphermans
05-17-2005, 07:22 AM
Is it possible to read records in a combobox and when i select one that the whole record displayed in a worksheet?
And how to do a link is also good.

Thnx.

Jacob Hilderbrand
06-07-2005, 03:11 PM
You can fill the ComboBox with a field from Access if you wanted. Then when you selected the record you wanted you could use something like this.




strSQL = "SELECT * " & _
"FROM (tablename) " & _
"WHERE (Criteria Here) & _
";"


Criteria could be something like:

"Where tablename.fieldname = """ & ComboBox1.Text & """



Dim Db As Database
Dim rs As Recordset
Dim i As Long
Set Db = OpenDatabase(DataBaseNameHere)
Set rs = Db.OpenRecordset(strSQL)
Sheets("SheetName").Range(CopyToRangeHere).CopyFromRecordset rs
rs.Close
Db.Close