Solved

dblist LIST FIELD error???

Posted on 1998-04-19
5
243 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now