Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DBgrid - General task

Posted on 2002-06-03
6
Medium Priority
?
153 Views
Last Modified: 2010-05-02
Hello Experts.
I have a procedure (Proc_1) that is doing tasks on a Dbgrid and Data.
I want this procedure to be a procedure that I can call from different forms in the program.
Therefore, I will have to call the procedure with different Dbgrids and Datas, and the procedure will perform the task.

Public Sub Proc_1(Dbgrid1, Data1)
  Dim The_Db as DBgrid
  Dim The_Data as Data
...
...
...

End Sub

Can anybody help and give me the solution?
Thanks
0
Comment
Question by:HESUS
[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
  • 3
  • 3
6 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7051402
Your sub should be in a standard module, and read rather like this (for type security):

Public Sub Proc_1(The_DB as DBGripd, The_Data as Data)

 ...
 ...
 ...

End Sub

Now, I don't see your problem?!
0
 

Author Comment

by:HESUS
ID: 7051577
I did it as follows:

Public Sub Proc_1(The_DB as DBGripd, The_Data as Data)

dim Db1 as DBgrid
dim Data1 as Data

set db1=The_DB
...
...

End Sub

But how do I send The_DB to this procedure?
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 total points
ID: 7051590
First,
Public Sub Proc_1(The_DB as DBGripd, The_Data as Data)

dim Db1 as DBgrid
dim Data1 as Data

set db1=The_DB
...

you don't need to use the SET db1 = THE_db, but you could use the The_DB variable instead.

Now, when you call this proc from your form, you simply call the procedure like this ( i assume that the grid and the data in that form are called MyGrid and MyData ):

Call Proc_1 (MyGrid, MyData)

Cheers
0
Independent Software Vendors: 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:HESUS
ID: 7053321
I did what you suggested,and the value of the 'MyGrid' that
the procedure receive is "".And I get an error message about a wrong type.
The value of the 'MyData' that the procedure receive is the MyData.Caption .
Please do not give up.
Thanks
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7053324
Can you send me your project (check my profile for the email address)
CHeers
0
 

Author Comment

by:HESUS
ID: 7054297
Sorry.
Your anwer is 100% correct. I had a mistake.
Many thanks.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

597 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