Function based on Function 
Author Message
 Function based on Function

I have a form with two list boxes. LstofTables uses the FillList function
to fill itself with names of all of the tables present in the current DB.
LstFields uses the FillFieldList to populate itself with names of all of
the fields for the tables selected in LstofTables.

Problem is, LstFields does not display anything evem though I get a
"Calculating" message at the bottom when I select a table name from
LstofTables. I've tried several creative attempts but have succeeded only
in chopping up  formerly neat code (thanks to "Programming in MS Access
2.0, p396). Can you help? The code (short and sweet) is below.

Public Function FillFieldList(ctlField As Control, varID As Variant, varRow
As Variant, varCol As Variant, varCode As Variant)

    Static astrTableName() As String
    Static intInc As Integer

    Dim db As DATABASE
    Dim dbsString As String
    Dim fldname As Field
    Dim intCount As Integer
    Dim varRetval As Variant
    Dim intLoop As Integer
    Dim intItems As Integer
    Dim tdfname As TableDef
    Dim TableName As String
    Dim varitem As Variant
    Dim ctlList As Control

    varRetval = Null

    Select Case varCode

     Case LB_INITIALIZE

    Set db = CurrentDb
    Set ctlList = Forms!frmCleanup_menu!lstOfTables
    For Each varitem In ctlList.ItemsSelected
    TableName = ctlList.ItemData(varitem)
    dbsString = TableName
    Set tdfname = db.TableDefs(dbsString)
    With tdfname

     intItems = .Fields.Count
                If intItems = 0 Then
                varRetval = False

                Else

                ReDim astrTableName(intItems)
                intInc = 0
                For Each fldname In .Fields
                    For intLoop = 0 To .Fields.Count - 1
                        Set fldname = db.TableDefs(intLoop)
                        astrTableName(intInc) = fldname.Name
                        intInc = intInc + 1

                    Next intLoop
                Next fldname
                    End If

                    varRetval = True
            End With
            Next varitem

        Case LB_OPEN
            ' Get a Unique ID number for control.
            varRetval = Timer
        Case LB_GETROWCOUNT
            ' Get the Number of rows.
            varRetval = intInc
        Case LB_GETCOLUMNCOUNT
            ' Get the Number of columns.
            varRetval = 1
        Case LB_GETCOLUMNWIDTH
            ' Get the Column width.
            ' Use default width.
            varRetval = -1
        Case LB_GETVALUE
            ' Get the actual data for the row.
            varRetval = astrTableName(varRow)
        Case LB_END
            ' Clean up (release memory)
            Erase astrTableName

    End Select
    FillFieldList = varRetval

End Function

--
S.E. Hanley

Applications Programmer
Callaway Gardens
Pine Mtn. GA



Fri, 09 Jun 2000 03:00:00 GMT  
 Function based on Function

Maybe I shouldn't even suggest this but what the heck.  Don't mind if the
suggestion sounds too dumb :-)

Code looks fine at first glance, do you have a
me!LstFields.Requery
from teh AfterUpdate event of lstOfTables???

--
Dev Ashish



Quote:
>Problem is, LstFields does not display anything evem though I get a
>"Calculating" message at the bottom when I select a table name from
>LstofTables. I've tried several creative attempts but have succeeded only
>in chopping up  formerly neat code (thanks to "Programming in MS Access
>2.0, p396). Can you help? The code (short and sweet) is below.
<snipped>

>--
>S.E. Hanley

>Applications Programmer
>Callaway Gardens
>Pine Mtn. GA



Sat, 10 Jun 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problem with GUID Generated by function GetGUID in knowledge base article

2. Query base for subreport function

3. Array function with parameter based recordset

4. SQL-based User Defined Functions

5. calling base class function in VB.NET

6. Run an overrides function from base class

7. Calling a function based on a variable name

8. Use of GetPrivateProfileString function in a 32-bit Windows-based application

9. Running Excel function from Access function/macro

10. findlast function is not functioning?

11. new type of aggregate function (product function)

12. functions calling other functions

 

 
Powered by phpBB® Forum Software