I have an Excel document that contains information that I want to use as my
rowsource for my combobox in Word. When I create a UserForm in Excel with a
combobox and try it, the string below works , but when I create a UserForm
in Word with a combo box, I get the error message "invalid property value".
The string I am trying to enter into rowsource property is listed below:
='C:\Backup\[Test Combo box.xls]Sheet1'!LastName
Any help on the proper way to enter this would be appreciated.
Missy Mason
See the article “Load a ListBox from a Named Range in Excel using DAO” at:
http://www.mvps.org/word/FAQs/InterDev/FillListBoxFromXLDAO.htm
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"Missy Mason" <news...@shaw.ca> wrote in message
news:f%sab.982237$ro6.19...@news2.calgary.shaw.ca...
I tried the DAO method, but it came back within invalid query string.
"Doug Robbins - Word MVP" <d...@mvps.org> wrote in message
news:#z0Teapf...@TK2MSFTNGP09.phx.gbl...
I just tried it and it works fine for me.
Post back to the newsgroup with a message into which you paste the exact
code that you have tried to use.
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"Missy Mason" <news...@shaw.ca> wrote in message
news:w_Dab.995032$3C2.22...@news3.calgary.shaw.ca...
I have attached the exact code that I am using. I have created a
spreadsheet called Test Combo box with a range called LastName (A1:A3).
When I run the code I get the error message: Syntax error in query.
Incomplete query clause.
Any help as to what I am doing incorrectly, would be greatly appreciated.
Dim db As DAO.database
Dim rs As DAO.recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("c:\backup\Test Combo box.xls", False, False, "Excel
8.0")
' Retrieve the recordset
Set rs = db.OpenRecordset("Select * from 'LastName'")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of columns - number of fields in recordset
Me.cmbxLawyer.ColumnCount = rs.Fields.Count
' Load the Combobox with the retrieved records
Me.cmbxLawyer.Column = rs.GetRows(NoOfRecords)
rs.Close
db.Close
Missy Mason
"Doug Robbins - Word MVP" <d...@mvps.org> wrote in message
news:#RyBx7Bg...@tk2msftngp13.phx.gbl...
Change this line:
Set rs = db.OpenRecordset("Select * from 'LastName'")
to
Set rs = db.OpenRecordset("Select * from LastName")
no apostrophes around the name of the range.
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"Missy Mason" <news...@shaw.ca> wrote in message
news:iFmbb.199253$la.39...@news1.calgary.shaw.ca...
Thank you so much. It works!!
Regards,
Missy Mason
"Doug Robbins - Word MVP" <d...@mvps.org> wrote in message
news:eaTZspJg...@tk2msftngp13.phx.gbl...