Solved

dblist LIST FIELD error???

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
to transfer string from C lanaguage to VBA 4 58
MS Date Picker 64 bit 32 bit issue 12 50
Visual Studio 2005 text editor 10 35
fso.FolderExists("\\server\HiddenFolder$") 4 52
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

863 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

19 Experts available now in Live!

Get 1:1 Help Now