• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

dblist LIST FIELD error???

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
tdog
Asked:
tdog
  • 2
  • 2
1 Solution
 
DalinCommented:
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
 
tdogAuthor Commented:
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
 
wokaCommented:
I seem to remember somethig about VB not handling fields with spaces in the field name.  Just a thought.
0
 
DalinCommented:
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
 
tdogAuthor Commented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now