Solved

DBgrid - General task

Posted on 2002-06-03
6
148 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 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 50 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…
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…

829 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