Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

dblist LIST FIELD error???

Posted on 1998-04-19
5
248 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 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