Solved

dblist LIST FIELD error???

Posted on 1998-04-19
5
246 Views
Last Modified: 2008-02-01
I am using a data-bound dblist box to show the content of an access file.  i am changing the listfield property of the dblist object at runtime so that the contents of the dblist box changes in response to user requests.  like this:

DBList1.ListField = "NORTH GRAND MALL"
Data1.RecordSource = "gresunsw"
Data1.Refresh

this works fine - the first time the listfield property is given a value, but when i change it a second time, i get a run-time error 380, invalid property error.  i tried to reinitialize the variable by using:

DBList1.ListField = ""

but i still get the error.  any suggestions from you experts.  also, is there any way to manipulate the position of the scroll bar (of the dblist box) during run time?
0
Comment
Question by:tdog
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:Dalin
ID: 1425157
tdog,
I assume you have data1 as the RowSource of your dbList

Thus, You need to refresh the data1 before you can change the listfield property. Otherwise, if the listfield is not in the old recordsset of data1(obviusely not, or nyou do not need to refresh).

Any more problems let me know
Regards
Dalin
0
 

Author Comment

by:tdog
ID: 1425158
well, i am going to open up this question to other experts.  i don't understand your answer.  i am refreshing data1 but i am still getting the run-time error 380 (invalid property value) on this statement:

DBList1.ListField = "AMES HIGH SCHOOL"

this statement works fine the first time it is read, but it fails the second time it the value of the listfield is changed.  

dalin, your answers are usually great, but i don't understand your answer so i have to reopen it.  i am down to crunch-time!

let me know if you think of anything else.

tdog
0
 
LVL 2

Expert Comment

by:woka
ID: 1425159
I seem to remember somethig about VB not handling fields with spaces in the field name.  Just a thought.
0
 
LVL 9

Accepted Solution

by:
Dalin earned 60 total points
ID: 1425160
Tdog,

Thank you for your feedback. I am sorry I did not make my self clear
The first time, and let me truy again.

Assume data1 is your rowsource of the listBox.  You set the listField
first, then reset the recordset of data1. The problem is that When you
set the  listfield, the field is not in your data1's recordset
yet (otherwise you do not need to change it). Thus the error occur

so Try this:

' Reset th Rowsource first
Data1.RecordSource = "gresunsw"
Data1.Refresh

'Now set the list field, assume "North Grand Mall"
  'is a field in "Gresunsw"
DBList1.ListField = "NORTH GRAND MALL"

VB can handle Field name with Space. When doing SQL, you need to
use [North Grand Mall].  I think your syntex is right since you
said it worked fine the first time.

By the way, Are you in Ames? I was study in ISU for my masters.

If you have more problems, let me know. Give a little more infor
about the rowsource.

Regards
Dalin

0
 

Author Comment

by:tdog
ID: 1425161
thanks dalin,
    i have been having trouble with submitting my responses, so that is why it has taken so long to get back with you.
    your solution seems to work well.  i just did not understand your first solution.
    i raised the points to 65.  i'm hoping you can tell me how to manipulate the scroll bar position on the dblist box during runtime.  the problem occurs when the number of records shown in the list box is too long to be displayed, so the dblist box automatically puts a scroll bar in.  if i move this scroll bar and then change the listfield property, the scroll bar does not return to its upmost position, so i lose so of the records when the listbox is updated with the new field.  any suggestions?

once again, thanks.  and yes, you are right = ISU in Ames, Iowa.

tdog
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question