Solved

DBgrid - General task

Posted on 2002-06-03
6
145 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
  • 3
  • 3
6 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
Comment Utility
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 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 total points
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:HESUS
Comment Utility
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 142

Expert Comment

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

Author Comment

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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

763 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

8 Experts available now in Live!

Get 1:1 Help Now