-
Dear Friends,
I now faced a big problem about passing parameters to a form module. Do you know how to pass parameters to a form module.
My trivial method is to declare a public variable in the form module and let the calling routine to set:
Sub CallingRoutine(MyParameter as ...)
frmForm.parameter=MyParameter
end sub
I faced an error that
Code:
Private Sub LoadNewDoc(MyDatabaseName As String, MyStockItem As String)
Static lDocumentCount As Long
Dim frmD As frmDocument
lDocumentCount = lDocumentCount + 1
Set frmD = New frmDocument
Debug.Print "MyDatabaseName=" & MyDatabaseName
Debug.Print "MyStockItem=" & MyStockItem
frmD.Caption = "Workspace " & lDocumentCount
frmD.CurDatabase = MyDatabaseName
frmD.CurStockItem = MyStockItem
frmD.Show
End Sub
frmDocument is as follows:
Code:
Option Explicit
Dim WithEvents adoPrimaryRS As Recordset
Dim mbChangedByCode As Boolean
Dim mvBookMark As Variant
Dim mbEditFlag As Boolean
Dim mbAddNewFlag As Boolean
Dim mbDataChanged As Boolean
Dim MousePoint As Integer
Public CurDatabase As String
Public CurStockItem As String
Private Sub Form_Load()
Debug.Print "Document Loaded"
'CurDatabase = lblCurDatabase.Caption
'CurStockItem = lblCurStockItem.Caption
Debug.Print "CurDatabase=" & CurDatabase
Debug.Print "CurStockItem=" & CurStockItem
Debug.Print Me.Caption
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & CurDatabase
Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "SELECT [Date],[Open],[High],[Low],[Close],[Volume] FROM Price WHERE [Ticker]=" & CurStockItem, db, adOpenStatic, adLockOptimistic
Set grdDataGrid.DataSource = adoPrimaryRS
mbDataChanged = False
Me.Caption = CurStockItem
' Put the first tab's frame on top at startup.
ctrlFrame(0).ZOrder 0
Form_Resize
End Sub
Authentication error has been resulted because the CurDatabase string is nothing.
Can you help me to solve this? Ensure CurDatabase
parameter is securely passed.
Thanks Thanks Thanks a lot.
-
Yes, One point to note
I wish to point out the
frmDocument is set to be a child form of a MDI form
will this matter?
Thanks.