someone plz help me with this vba coding!!!!!

shy216

New member
Local time
Today, 06:00
Joined
Jul 12, 2005
Messages
7
im new at vba and i have no idea why this coding is not working. it's suppose to let me search for a name but i get an error. It's a simple popup page that has a field i can type the "payer" name and search from the form "LogTxTable". When i type the name i want to search for and click ok, i get a Compile error: sub or function not defired.
and it also highlights private sub cmdSome_Click() yellow and also highlights IsNothing in blue. I copied this coding from other database and pretty much changed the names. Is there something wrong with decarling? any kind of help would be appreciated. thank you.




Code:
Option Compare Database
Option Explicit


Private Sub cmdCancel_Click()
    DoCmd.Close acForm, Me.Name
End Sub

Private Sub cmdSome_Click()
Dim varWhere As Variant

    'set and error trap
    On Error GoTo cmdSome_Err
    
    'Initialize to Null
    varWhere = Null
    
    'If specified Payer
    If Not IsNothing(Me.txtPayer) Then
    
        varWhere = "[Payer] LIKE '" & Me.txtPayer & "*'"
    End If
    
    If IsNothing(varWhere) Then
        MsgBox "You must enter at least one search criteria.", vbInformation, gstrAppTitle
        Exit Sub
    End If
    
    'close the form if it's open
    
    If IsFormLoaded("frmLogTxTable") Then
        If vbYes = MsgBox("The Members window is already open.  This search " & "will cancel any pending edits in that window, close it, and " & "attempt to reopen with the criteria you specified." & vbCrLf & vbCrLf & "Are you sure you want to proceed?", vbQuestion + vbYesNo + vbDefaultButton2, gstrAppTitle) Then
        
            Form_frmLogTxTable.cmdCancel_Click
        Else
            Exit Sub
        End If
    End If
    'open frmLogTxTable
    DoCmd.OpenForm FormName:="frmLogTxTable", whereCondition:=varWhere, WindowMode:=acHidden
    If Forms!frmLogTxTable.RecordsetClone.RecordCount = 0 Then
        'no orders for selected customers
        MsgBox "There are no members that match the selected criteria.", vbInformation, gstrAppTitle
        DoCmd.Close acForm, "frmLogTxTable"
        Exit Sub
    Else
        Forms!frmLogTxTable.Visible = True
    End If
    DoCmd.Close acForm, Me.Name
    
cmdSome_Exit:
        Exit Sub
cmdSome_Err:
    ErrorLog Me.Name & "_cmdSome", Err, Error
    MsgBox "Unexpected error: " & Err & ", " & Error, vbCritical, gstrAppTitle
    Resume cmdSome_Exit
End Sub
 
Last edited by a moderator:
-now it's doing it same thing but says IsFormLoaded is highlighted...


Code:
Option Compare Database   'Use database order for string comparisons
Option Explicit

Public Sub cmdCancel_Click()
    DoCmd.Close acForm, Me.Name
End Sub
Private Sub cmdNew_Click()

    ' Set error trap
    On Error GoTo cmdNew_Err
    
    Me.Visible = False
    ' Close the form if it is open
    If IsFormLoaded("frmLogTxTable") Then
        If vbYes = MsgBox("The Log Table window is already open.  Starting " & _
            "a new record will cancel any pending edits in that window, close it, " & _
            "and reopen on a new Log record." & _
            vbCrLf & vbCrLf & "Are you sure you want to proceed?", _
            vbQuestion + vbYesNo + vbDefaultButton2, gstrAppTitle) Then
            ' Close using the form's Cancel routine
            Form_frmLogTxTable.cmdCancel_Click
        Else
            Exit Sub
        End If
    End If
    DoCmd.OpenForm FormName:="frmLogTxTable", DataMode:=acFormAdd
    Forms!frmLogTxTable.SetFocus
    ' Close me
    DoCmd.Close acForm, Me.Name
    
cmdNew_Exit:
    Exit Sub
    
cmdNew_Err:
    ErrorLog Me.Name & "_cmdNew", Err, Error
    MsgBox "Unexpected error: " & Err & ", " & Error, vbCritical, gstrAppTitle
    Resume cmdNew_Exit
End Sub


Private Sub cmdSome_Click()
Dim varWhere As Variant

    ' Set an error trap
    On Error GoTo cmdSome_Err

    ' Initialize to Null
    varWhere = Null
    
    ' If specified a last name value
    If Not IsNothing(Me.txtPayer) Then
        ' .. build the predicate
        varWhere = "[Payer] LIKE '" & Me.txtPayer & "*'"
    End If
    
    ' Check to see that we built a filter
    If IsNothing(varWhere) Then
        MsgBox "You must enter at least one search criteria.", vbInformation, gstrAppTitle
        Exit Sub
    End If
        
    ' Close the form if it is open
    If IsFormLoaded("frmLogTxTable") Then
        If vbYes = MsgBox("The Log Table window is already open.  This search " & _
            "will cancel any pending edits in that window, close it, and " & _
            "attempt to reopen with the criteria you specified." & _
            vbCrLf & vbCrLf & "Are you sure you want to proceed?", _
            vbQuestion + vbYesNo + vbDefaultButton2, gstrAppTitle) Then
            ' Close using the form's Cancel routine
            Form_frmLogTxTable.cmdCancel_Click
        Else
            Exit Sub
        End If
    End If
    ' Open frmCustomers hidden to check if any for selected customers
    DoCmd.OpenForm FormName:="frmLogTxTable", WhereCondition:=varWhere, WindowMode:=acHidden
    If Forms!frmLogTxTable.RecordsetClone.RecordCount = 0 Then
        ' No orders for selected customers
        MsgBox "There are no members that match the selected criteria.", _
            vbInformation, gstrAppTitle
        DoCmd.Close acForm, "frmLogTxTable"
        Exit Sub
    Else
        Forms!frmLogTxTable.Visible = True
    End If
    ' Close me
    DoCmd.Close acForm, Me.Name
    
cmdSome_Exit:
    Exit Sub
    
cmdSome_Err:
    ErrorLog Me.Name & "_cmdSome", Err, Error
    MsgBox "Unexpected error: " & Err & ", " & Error, vbCritical, gstrAppTitle
    Resume cmdSome_Exit
End Sub
 
Last edited by a moderator:
IsFormLoaded() is not an Access intrinsic as far as i'm aware: if you don't have a function by that name in scope, expect the error you got.

izy
 
shy216 said:
I copied this coding from other database and pretty much changed the names.

First you need to make sure you copied all the other functions that they reference from that function. Then you need to change those function names too. You should also include a comment at the top of the code saying where you got the code from as not to infringe on any copyrights (and its also good faith to the author)
 
Last edited:
Shy,

Go to the Database window, select the Modules tab, and copy them to
your database too. One of the module(s) probably has your missing
function.

Wayne
 
Shy,
Although Wayne provided a solution, realize that your database is going to have extra functions that you may never use. It is not good database practice to load unecessary procedures into memory. Not only will this expand the size of your database, but it can cause it to slow down in the future.

For optimal performance, do as I had suggested and just copy the functions you need.
 
modest said:
Shy,
It is not good database practice to load unecessary procedures into memory. Not only will this expand the size of your database, but it can cause it to slow down in the future.

For optimal performance, do as I had suggested and just copy the functions you need.

How do you arrive at that conclusion? If a function's not called then it doesn't get loaded into memory.
 
If a function is in the same module as another function that's called, it does.
 
If a function is referenced, and it's not in a module, it makes a sound!

That's far better than the alternative.

Granted, things might be better, but let's get it working first.

Wayne
 
We don't train police to shoot every suspect to make sure we get the guy. Let's not teach bad practices, especially in beginning stages to people who might not know better, just to save time.

Demonstrating bad practice warrants bad habits.
 

Users who are viewing this thread

Back
Top Bottom