| | |
Transferring variables across forms in VB6
Thread Solved |
Hello,
I have been trying with no success to transfer a recordset from one form to another.
I have declared in Form1 that
All works lovely in Form1
In Form2 when I use
I get an error message at runtime
I have managed to get around the problem by stating all of my variables as Public in a Module, but from what I have read this may be poor practice.
Any help would be much appreciated.Thanks
P.S Does anybody find the ADO control even remotely easy to understand.
I have been trying with no success to transfer a recordset from one form to another.
I have declared in Form1 that
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Public myRS As ADODB.Recordset
All works lovely in Form1
In Form2 when I use
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub cmdFail_Click(ByVal myRS As ADODB.Recordset)
I get an error message at runtime
•
•
•
•
Compile Error Procedure Declaration does not match description of event or procedure having the same name.
Any help would be much appreciated.Thanks
P.S Does anybody find the ADO control even remotely easy to understand.
Ther are 10 types of people in the world. Those who do understand binary and those who don't!!
Nice one.Thanks for the reply.Having used this method with other types of variables I am sure this will work.I am working on a multiple form project and will try out this method on one of them.I will let you know how things go.
I would still be interested to know, if anyone can help , how to introduce the variable as a public variable from another form in the routine name ie
Thanks very much for your reply. All suggestions help.
And thanks for the Class Module suggestion. I shall have a read.
I would still be interested to know, if anyone can help , how to introduce the variable as a public variable from another form in the routine name ie
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub cmdCommand(ByVal introduce Public recordset)
Thanks very much for your reply. All suggestions help.
And thanks for the Class Module suggestion. I shall have a read.
Last edited by lostandfound; Jan 21st, 2008 at 5:53 pm. Reason: Add a bit,Spelling
Ther are 10 types of people in the world. Those who do understand binary and those who don't!!
If you always use that function/procedure try to put that in a module so that anyone can access that procedure/function
Here's a sample...
Declare this in a module
in your form...
Enjoy Coding....
regards:
Here's a sample...
Declare this in a module
•
•
•
•
Public Function dbOpenRecordSet(sqlcmd as String) as Recordset
1. if your database was not yet open, then open it.
2. open a recordset with the query in the sqlcmd (sqlcmd the variable who holds your query.
•
•
•
•
Dim sqlcmd as String
sqlcmd = "select * from mytable"
dbOpenRecordSet(sqlcmd)
If Not dbOpenRecordset.EOF Then
put here what you want to the data...
End If
regards:
Last edited by jireh; Jan 21st, 2008 at 8:16 pm.
A conclusion is the place where you got tired of thinking. http://www.martin2k.co.uk/forums/index.php?showforum=4
http://www.a1vbcode.com/a1vbcode/vbforums/Forum3-1.aspx
http://www.developerfusion.co.uk/for...orum&ForumID=4
Whoa,whoa,whoa,
Now I'm more confused. Are you describing an example which includes the use of the ADO control. There is a fair bit here that I don't recognise.
I understand that there are several ways to read and write to and from a database. I am currently struggling with the ADO as it seems to be the control of choice for those who know the difference.
Excuse me for my ignorance as I am by no means an expert.
I am happy with the idea of modules (hkdani has set me some homework on class modules which I must attend to).
It still seems to me that if I have opened a connection from my project to an associated database that there should be some way of using that connection across all the forms in that project.(Surely there is a logical way of transferring the properties of the objects involved across the board)
Jireh, please, if there is somrthing I am not grasping with regard to your reply could you explain.
Thanks for the help
Now I'm more confused. Are you describing an example which includes the use of the ADO control. There is a fair bit here that I don't recognise.
I understand that there are several ways to read and write to and from a database. I am currently struggling with the ADO as it seems to be the control of choice for those who know the difference.
Excuse me for my ignorance as I am by no means an expert.
I am happy with the idea of modules (hkdani has set me some homework on class modules which I must attend to).
It still seems to me that if I have opened a connection from my project to an associated database that there should be some way of using that connection across all the forms in that project.(Surely there is a logical way of transferring the properties of the objects involved across the board)
Jireh, please, if there is somrthing I am not grasping with regard to your reply could you explain.
Thanks for the help
Ther are 10 types of people in the world. Those who do understand binary and those who don't!!
•
•
•
•
It still seems to me that if I have opened a connection from my project to an associated database that there should be some way of using that connection across all the forms in that project.(Surely there is a logical way of transferring the properties of the objects involved across the board)
You'll notice that Class Modules have a Data Source and a Data Binding Property.
You write the code to initialize the ADO Database objects and to terminate or close them in the class module.
You can then access this class module from anywhere in your project. Usually, in a form.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Option Explicit Dim MyCounter as cmCounter Private Sub Form_Load set MyCounter = new cmCounter ' ' End sub Private Sub Form_Unload ' Close out your class module set MyCounter = nothing End sub
Check out the MSDN documentation, if you have the CD's Look for the section Accessing Data Using Visual Basic under the Data Access Guide.
Using Visual Basic/Data Access Guide/Accessing Data Using Visual Basic
Hank
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: how to fill a web form using sendkeys
- Next Thread: How to access LPTSTR data in VB
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





