returning a variable from a form to a VBA procedure

C

csticht

I am trying to get the table name back from a form where the table is
selected with a mouse click. I am trying to use a Public variable, but
it does not seem to work.
Does anyone know of a way to get a variable back from a form? My code
is copied below for my procedure and my form.


****This is the code from my Procedure****
Public sTable As String
Dim db As Database
Dim rsC As Recordset, rsP As DAO.Recordset
Dim sFrmMsgs As String
Sub Estimate4()
Set db = CurrentDb
sFrmMsgs = "Select the Current year's meter reads Table"
DoCmd.OpenForm "frmTableSelect", , , , , acDialog, sFrmMsgs
Set rsC = db.OpenRecordset("SELECT * FROM " & sTable & ";")
sFrmMsgs = "Select the Previous year's meter reads Table"
DoCmd.OpenForm "frmTableSelect", , , , , acDialog, sFrmMsgs
Set rsP = db.OpenRecordset("SELECT * FROM " & sTable & ";")
End Sub
Function RunEstimate4()
Estimate4
End Function

****This is the code from my form****
Dim db As Database
Dim varstr As String
Dim tdfLoop As TableDef
Dim i As Integer
Set db = CurrentDb()
With db
For Each tdfLoop In .TableDefs
varstr = varstr & tdfLoop.Name & ", "
Next tdfLoop
End With
Me.List0.RowSourceType = "Value List"
Me.List0.RowSource = varstr
End Sub

Private Sub List0_Click()
sTable = Me.List0
DoCmd.Close
End Sub


Thanks
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top