[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

DBCombo Box

Posted on 1997-11-22
7
Medium Priority
?
406 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
  • 4
  • 3
7 Comments
 
LVL 5

Accepted Solution

by:
dirtdart earned 100 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

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!

Question has a verified solution.

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

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…
Suggested Courses

868 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