Solved

DBCombo Box

Posted on 1997-11-22
7
386 Views
Last Modified: 2008-03-06
Hi all,

I'm using visual basic 4. My program contains 2 forms and one module. Form1 has a DBCombo box style 1, a Data Control which is connected with the DBCombo and my access file and a command button. Form2 has few text boxes  and a Data Control with the necessary connection between it and the text boxes and my access file.

In the lower portion of my DBCombo in Form1 a list of movie titles are displayed from my access file. The user will type the title he is looking for in the upper portion of the DBCombo and the list of titles will automatically scroll down according to what the user types (that is because it's style 1). Once the title have been allocated in the list I then want my program to display information of that particular title in the text boxes in form2 when the user clicks on the command button in Form1.  This is the code I have come up with so far:

First I type the following in my module

      Public varname
      Public MovieName
      Public Count
      Count = 0

Second I typed the following in my button command click

      MovieName = Combo1.Text
      load form2
      form2.show
      Count = 1

Finally I typed the following in my Form2 load

If count = 0 then
Data1.RecordSource = varname
Else
data1.recordset.findfirst "fieldname =" & "'" & MovieName & "'"
count = 0

However when I try running my program I get an Error message saying "Invalid Outside Procedure" on the zero in the statement "count = 0" in the module. What am I doing wrong? And does anyone have any better ideas on how to make my DBCombo work? Your help is appreciated! :)

Thanx
Belle
0
Comment
Question by:Belle
[X]
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
  • 4
  • 3
7 Comments
 
LVL 5

Accepted Solution

by:
dirtdart earned 50 total points
ID: 1442094
You can't directly set values of variables in the General Declarations section of a module.  If Form1 is your main form, place your Count = 0 in the Form_Load event of Form1.

As far as how your DBCombo works, it looks pretty good to me except that I don't like using data bound controls, but that's just personal opinion.
0
 

Author Comment

by:Belle
ID: 1442095
Hi again,

I Placed Count = 0 in the form_load of my form1 but when I tried running my program I got an error at the "count =" which I have just placed in the form_load with a message saying "Function call on the left-hand side of assignment must return Variant or Object". I'm not really sure what's that asking me to do. Can you help?

Thanx
Belle

0
 
LVL 5

Expert Comment

by:dirtdart
ID: 1442096
I see the problem now.  Count is a reserved word.  I'm not sure exactly what it refers to, but VB won't let you use it.  Pick another variable name (I usually use ct for counters) and declare  it public in your module, then do a find and replace in the rest of  your code, and you should be alright.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Belle
ID: 1442097
Hi again,

Umm sorry I'm new at Visual Basic, I did change my variable name to cntr but when I run my program now and click on the command button in Form1 I get nothing in my text boxes in Form2 other than their names (Text1, Text2 and so on). It's not retrieving the data of that specific Title the user chose from the DBCombo for some reason, and I'm not so sure what you ment by "do a find" and how it is done, can you direct me some more if it's not so much trouble, thanx :)

Belle
0
 
LVL 5

Expert Comment

by:dirtdart
ID: 1442098
By do a find and replace, I just meant click on the Edit menu, then click Find and Replace.  Basically, just make sure all instances of Count are replaced with your new variable.  Find and Replace is just the easiest way to do that.  Just like in a word processor.

I notice that you didn't set the DataSource and DataField properties of your text boxes.  That's probably why you didn't get any information. If you are setting the Data1.DataSource at runtime, and not the Text1.DataSource and Text1.DataField, then the text box doesn't know which field to bind to.  DataSource would be Data1, and DataField would be whatever field in the data source that you are trying to display.
0
 

Author Comment

by:Belle
ID: 1442099
I may have not included the setting of the text1.datasource and the text1.datafield in my code but I have set them in the properties window of the text boxes so I'm still trying to figure out why it won't display the data from my access file in form2.
0
 
LVL 5

Expert Comment

by:dirtdart
ID: 1442100
If you'd like, zip up your project and send it to me at dirtdart@apex.net.  I'll take a look at it for you.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

734 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