Private Sub MDIForm_Load()

show
Me.BackColor = &H80000005
HideTBButton "", True
frmShortcuts.show

CrystalReport0.Connect = "westranet.westham.com.my" & ";UID=sa;PWD=123;DSQ=WMS_TEST;"


**Error point on Connect

Edited 5 Years Ago by feedz87: n/a

I want connect my system to Crystal report,when i run the system that error will be show.The error is at correct word.What is more information do you need to know?

Are you sure that the name of the component is

CrystalReport0

and not "CrystalReport1" or "CrystalReport01"?


Try using

Option Explicit

on the top of your form (should be the very first line of code, outside any procedure - sub or function).

This error occurs when you use a method name that is not supported (or no longer exists) in the object.
Assuming the Crystal Report object HAS the Connect property, maybe the variable name (CrystalReport0) was spelled wrong.

Make sure Connect is a property, by the way. If Connect is a method, you shouldn't use the "=" sign in the call. I don't work with Crystal Reports, so I don't mind what Connect is (property or method).

Sidnei

Edited 5 Years Ago by sidnei: correct misspeled word

Option Explicit

'Var for point api function
Dim cursor_pos As POINTAPI

Public CloseMe  As Boolean

Dim resize_down     As Boolean
Dim show_mnu        As Boolean
Dim pos_num         As Integer



Private Sub Command1_Click()

End Sub

Private Sub lvWin_Click()
    If lvWin.ListItems.count < 1 Then Exit Sub
    
    Select Case lvWin.SelectedItem.Key
        Case "frmShortcuts": frmShortcuts.show: frmShortcuts.WindowState = vbMaximized: frmShortcuts.SetFocus
        
        'For Routes
        'Case "frmRoutes": LoadForm frmRoutes
        
        'For Agents
        'Case "frmAgents": LoadForm frmAgents
        
        'For Cargos
        'Case "frmCargos": LoadForm frmCargos
        
        'For Banks
        Case "frmBanks": LoadForm frmBanks
        
        'For Service Type
        Case "frmService": LoadForm frmService
        
        'For Warehouses
        Case "frmWarehouses": LoadForm frmWarehouses
        
        'For Clients
        Case "frmCustomers": LoadForm frmCustomers
        'Case "frmCustomerBalance": LoadForm frmCustomerBalance
        'Case "frmCustomersCategory": LoadForm frmCustomersCategory
        'Case "frmCities": LoadForm frmCities
        
        'For Vendors
        'Case "frmSuppliers": LoadForm frmSuppliers
        'Case "frmSuppliersLocation": LoadForm frmSuppliersLocation
        'Case "frmVendorBalance": LoadForm frmVendorBalance

        'For ShippingCompany
        'Case "frmShippingCompany": LoadForm frmShippingCompany
        'Case "frmLocalForwarder": LoadForm frmLocalForwarder
        'Case "frmShipCoBalance": LoadForm frmShipCoBalance
        
        'For Stocks
        'Case "frmProducts": LoadForm frmProducts
        'Case "frmProductsCategory": LoadForm frmProductsCategory
        'Case "frmProductsUOM": LoadForm frmProductsUOM
        
        'For Sales
        'Case "frmSalesReceipts": LoadForm frmSalesReceipts
        'Case "frmSalesReceiptsBatch": LoadForm frmSalesReceiptsBatch
        'Case "frmSalesReturnReceipts": LoadForm frmSalesReturnReceipts
                
        'For Purchases
        'Case "frmPurchaseOrder": LoadForm frmPurchaseOrder
        'Case "frmForwardersGuide": LoadForm frmForwardersGuide
        'Case "frmPOReceiveLocal": LoadForm frmPOReceiveLocal
        'Case "frmForwardersReceive": LoadForm frmForwardersReceive
        'Case "frmPOReturn": LoadForm frmPOReturn
        
        'For Collection
       ' Case "frmCollection": LoadForm frmCollection
        
        Case "frmUserRec"
            If CurrUser.USER_ISADMIN = False Then
                MsgBox "Only admin users can access this record.", vbCritical, "Access Denied"
            Else
                frmUserRec.show vbModal
            End If
        Case "frmBusinessInfo": frmBusinessInfo.show vbModal
    End Select
End Sub

Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If CloseMe = False Then If MsgBox("This will close the application. Do you want to proceed?", vbExclamation + vbYesNo) = vbNo Then Cancel = 1: Exit Sub
    'FRM_MESSAGE.show vbModal
End Sub

Private Sub MDIForm_Resize()
    On Error Resume Next
    picFreeMem.Left = (Me.Width - picFreeMem.ScaleWidth) - 200
End Sub

Private Sub MDIForm_Terminate()
Set MAIN = Nothing

If conn.State = adStateOpen Then
    conn.Close
End If

End Sub

Private Sub mnu_AdditionalCharges_Click()
frmJobCharges.show 1
End Sub

Private Sub mnu_AllCharges_Click()
frmgeneral.show vbModal
End Sub

Private Sub mnu_AuditJob_Click()
frmRptAuditJob.show 1
End Sub





Private Sub mnu_ChangePwd_Click()
    'LoadForm frmChangePwdAE
    frmChangePwdAE.show vbModal
End Sub

Private Sub mnu_Clients_Click()
    LoadForm frmCustomers
End Sub

Private Sub mnu_ContainerSize_Click()
    LoadForm frmContainerSize
End Sub

Private Sub mnu_fininv_Click()
frmfinance.show vbModal
End Sub

Private Sub mnu_Inventory_Click()
frmRptInventory.show 1
End Sub

Private Sub mnu_NewJobOrder_Click()
    LoadForm frmJobOrderNew
End Sub

Private Sub mnu_Old_Inventory_Click()
frmRptInventoryOld.show 1
End Sub

Private Sub mnu_Old_Operation_Click()
frmRptOperationOld.show 1
End Sub

Private Sub mnu_OldJobOrder_Click()
    LoadForm frmJobOrder
End Sub

Private Sub mnu_Operations_Click()
frmRptOperation.show 1
End Sub

Private Sub mnu_Oprt_Reports_Click()
frmoprt.show vbModal
End Sub

Private Sub mnu_searchTransac_Click()
search.show vbModal
End Sub

'Private Sub mnu_Vendors_Category_Click()
'    LoadForm frmVendorsCategory
'End Sub

'Private Sub mnu_Vendors_Click()
'    LoadForm frmVendors
'End Sub

Private Sub mnu_Suppliers_Click()
    'LoadForm frmSuppliers
End Sub

Private Sub mnu_Thru_Reports_Click()
frmthroughput.show vbModal
End Sub

Private Sub mnuBanks_Click()
    LoadForm frmBanks
End Sub

Private Sub mnuFE_Click()
    Unload Me
End Sub

Private Sub mnuFLO_Click()
    If MsgBox("Are you sure you want to log out?", vbQuestion + vbYesNo) = vbNo Then Exit Sub

    
    'SendMessage frmShortcuts.hwnd, WM_CLOSE, 0, 0
    UnloadChilds
    SendMessage frmShortcuts.hwnd, WM_ACTIVATE, 0, 0
    
    'ClearInfoMsg
    StatusBar1.Panels(3).Text = ""
    StatusBar1.Panels(4).Text = ""
    
    CurrUser.USER_NAME = ""
    CurrUser.USER_PK = 0
    
    
    frmLogin.show vbModal: If CloseMe = True Then Unload Me: Exit Sub: Exit Sub
    DisplayUserInfo
    'UpdateInfoMsg
End Sub



Private Sub mnuPackageType_Click()
    LoadForm frmPackageType
End Sub

Private Sub mnuRAC_Click()
    On Error Resume Next
    ActiveForm.CommandPass "Close"
End Sub

Private Sub mnuRACN_Click()
    On Error Resume Next
    ActiveForm.CommandPass "New"
End Sub

Private Sub mnuRADS_Click()
    On Error Resume Next
    ActiveForm.CommandPass "Delete"
End Sub

Private Sub mnuRAES_Click()
    On Error Resume Next
    ActiveForm.CommandPass "Edit"
End Sub

Private Sub mnuRAP_Click()
    On Error Resume Next
    ActiveForm.CommandPass "Print"
End Sub

Private Sub mnuRARR_Click()
    On Error Resume Next
    ActiveForm.CommandPass "Refresh"
End Sub

Private Sub mnuRAS_Click()
    On Error Resume Next
    ActiveForm.CommandPass "Search"
End Sub

Private Sub mnuRASSM_Click()
    frmShortcuts.show
    frmShortcuts.WindowState = vbMaximized
    frmShortcuts.SetFocus
End Sub

Private Sub mnuService_Click()
    LoadForm frmService
End Sub

Private Sub mnuSMMU_Click()
    If CurrUser.USER_ISADMIN = False Then
        MsgBox "Only admin users can access this record.", vbCritical, "Access Denied"
    Else
        frmUserRec.show vbModal
    End If
End Sub

Private Sub mnuSOAD_Click()
    frmShortcuts.lvMenu.View = lvwIcon
End Sub

Private Sub mnuSOAHL_Click()
    frmShortcuts.lvMenu.View = lvwSmallIcon
End Sub

Private Sub mnuSOAVL_Click()
    frmShortcuts.lvMenu.View = lvwList
End Sub

Private Sub mnuSSS_Click()
    frmSplash.DisableLoader = True
    frmSplash.show vbModal
End Sub

Private Sub mnuTasks_Click()
    LoadForm frmTasks
End Sub

Private Sub mnuUBI_Click()
    frmBusinessInfo.show vbModal
End Sub

Private Sub mnuUC_Click()
    On Error Resume Next
    Shell "calc.exe", vbNormalFocus
End Sub

Private Sub mnuUN_Click()
    On Error Resume Next
    Shell "notepad.exe", vbNormalFocus
End Sub

Private Sub mnuUWE_Click()
    On Error Resume Next
    Shell "Explorer.exe", vbNormalFocus
End Sub

Private Sub mnuWarehouses_Click()
    LoadForm frmWarehouses
End Sub



Private Sub StyleButton2_Click()
    show_mnu = Not show_mnu
    show_menu (show_mnu)
End Sub

Private Sub show_menu(ByVal show As Boolean)
    Dim img As Image
    If show = True Then
        Set img = Image2
    Else
        Set img = Image5
    End If
    'Set the style button graphics
    With StyleButton2
        Set .PictureDown = img.Picture
        Set .PictureFocus = img.Picture
        Set .PictureHover = img.Picture
        Set .PictureUp = img.Picture
    End With
    'Set picture visibility
    picLeft.Visible = show
    
    If show = True Then StyleButton2.ToolTipText = "Hide": picSeparator.MousePointer = vbSizeWE Else picSeparator.MousePointer = vbArrow: StyleButton2.ToolTipText = "Expand"
    
    Set img = Nothing
End Sub

Private Sub picSeparator_Resize()
    Call center_obj_vertical(picSeparator, StyleButton2)
End Sub

Public Sub HideTBButton(ByVal srcPatern As String, Optional srcAllButton As Boolean)
    If srcAllButton = True Then srcPatern = "ttttttt"
    If Mid$(srcPatern, 1, 1) = "t" Then tbMenu.Buttons(3).Visible = False: mnuRACN.Visible = False
    If Mid$(srcPatern, 2, 1) = "t" Then tbMenu.Buttons(4).Visible = False: mnuRAES.Visible = False
    If Mid$(srcPatern, 3, 1) = "t" Then tbMenu.Buttons(5).Visible = False: mnuRAS.Visible = False
    If Mid$(srcPatern, 4, 1) = "t" Then tbMenu.Buttons(6).Visible = False: mnuRADS.Visible = False
    If Mid$(srcPatern, 5, 1) = "t" Then tbMenu.Buttons(7).Visible = False: mnuRARR.Visible = False
    If Mid$(srcPatern, 6, 1) = "t" Then tbMenu.Buttons(8).Visible = False: mnuRAP.Visible = False
    If Mid$(srcPatern, 7, 1) = "t" Then tbMenu.Buttons(9).Visible = False: mnuRAC.Visible = False
    If mnuRAC.Visible = False Then mnuRASep2.Visible = False
End Sub

Public Sub ShowTBButton(ByVal srcPatern As String, Optional srcAllButton As Boolean)
    'Highligh active form in opened form list
    If srcAllButton = True Then srcPatern = "ttttttt"
    If Mid$(srcPatern, 1, 1) = "t" Then tbMenu.Buttons(3).Visible = True: mnuRACN.Visible = True
    If Mid$(srcPatern, 2, 1) = "t" Then tbMenu.Buttons(4).Visible = True: mnuRAES.Visible = True
    If Mid$(srcPatern, 3, 1) = "t" Then tbMenu.Buttons(5).Visible = True: mnuRAS.Visible = True
    If Trim(CurrUser.USER_CATEGORY) = "Supervisor" Then
        If Mid$(srcPatern, 4, 1) = "t" Then tbMenu.Buttons(6).Visible = True: mnuRADS.Visible = True
    Else
        If Mid$(srcPatern, 4, 1) = "t" Then tbMenu.Buttons(6).Visible = True: mnuRADS.Visible = False
    End If
    If Mid$(srcPatern, 5, 1) = "t" Then tbMenu.Buttons(7).Visible = True: mnuRARR.Visible = True
    If Mid$(srcPatern, 6, 1) = "t" Then tbMenu.Buttons(8).Visible = True: mnuRAP.Visible = True
    If Mid$(srcPatern, 7, 1) = "t" Then tbMenu.Buttons(9).Visible = True: mnuRAC.Visible = True
    If mnuRAC.Visible = True Then mnuRASep2.Visible = True
End Sub

Public Sub ShowMe()
    Me.Visible = True
End Sub

Private Sub MDIForm_Load()

    show
    Me.BackColor = &H80000005
    HideTBButton "", True
    frmShortcuts.show
    
'    Crystal report connection - use only 1 connection for all reports
    CrystalReport0.[B]Connect[/B] = "westranet.westports.com.my" & ";UID=sa;PWD=west1234;DSQ=WMS_TEST;"

   


    
'    DBPath = GetINI("VT Settings", "Path")      'get path from file
'    If Trim(DBPath) = "" Or IsNull(DBPath) Then
'JumpHere:
'      frmLocate.show 1                            'browse database
'    End If
    
'    If OpenDB = vbRetry Then GoTo JumpHere
    
    'create DSN for reports
'    createDSN
    
    frmLogin.show vbModal: If CloseMe = True Then Unload Me: Exit Sub: Exit Sub
    
    'Set the control properties
    Set lvWin.SmallIcons = i16x16
    Set lvWin.Icons = i16x16
    
    DisplayUserInfo
    
    lvWin.ListItems.Add(, "frmShortcuts", "@Shortcuts", 1, 1).Bold = True
    
    show_mnu = True
    show_menu (show_mnu)
    
    If Trim(CurrUser.USER_CATEGORY) <> "Supervisor" Then
        tbMenu.Buttons(6).Enabled = False
        mnu_AdditionalCharges.Visible = False
        mnu_AuditJob.Visible = False
    End If
   
  
End Sub

Private Sub DisplayUserInfo()
    'Display the current user info
    If CurrUser.USER_ISADMIN = True Then
        StatusBar1.Panels(4).Text = "Admin"
    Else
        StatusBar1.Panels(4).Text = "Operator"
    End If
    StatusBar1.Panels(3).Text = CurrUser.USER_NAME
    
    Dim rs As New Recordset
    
    'rs.Open "SELECT * FROM TBL_BUSINESS_INFO", CN, adOpenStatic, adLockReadOnly
    rs.Open "SELECT * FROM TBL_BUSINESS_INFO", conn, adOpenStatic, adLockBatchOptimistic, adCmdText
    'rs.Open "SELECT * FROM TBL_BUSINESS_INFO", CN, adOpenStatic, adLockBatchOptimistic
    
    CurrBiz.BUSINESS_NAME = rs.Fields(0)
    CurrBiz.BUSINESS_ADDRESS = rs.Fields(1)
    CurrBiz.BUSINESS_CONTACT_INFO = rs.Fields(2)
    
    Set rs = Nothing
    
    
End Sub

Public Sub AddToWin(ByVal srcDName As String, ByVal srcFormName As String)
    On Error Resume Next
    Dim xItem As ListItem
    
    Set xItem = lvWin.ListItems.Add(, srcFormName, srcDName, 1, 1)
    xItem.ToolTipText = srcDName
    xItem.SubItems(1) = "***" & srcDName & "***"
    xItem.Selected = True
    
    Set xItem = Nothing
End Sub

Public Sub RemToWin(ByVal srcDName As String)
    On Error Resume Next
    search_in_listview lvWin, "***" & srcDName & "***"
    lvWin.ListItems.Remove (lvWin.SelectedItem.Index)
End Sub


Private Sub MDIForm_Unload(Cancel As Integer)
    Set MAIN = Nothing
    If conn.State = adStateOpen Then
        conn.Close
    End If
End Sub

Private Sub mnuA_Click()
    frmAbout.show vbModal
End Sub

Private Sub mnuHKS_Click()
    'AddTest
End Sub

Private Sub picLeft_Resize()
    On Error Resume Next
    Frame1.Width = picLeft.ScaleWidth
    lvWin.Width = picLeft.ScaleWidth
    lvWin.Height = picLeft.ScaleHeight - lvWin.Top - 20
End Sub

Private Sub picSeparator_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If show_mnu = False Then Exit Sub
    If Button = vbLeftButton Then
        tmrResize.Enabled = True
        resize_down = True
    End If
End Sub

Private Sub picSeparator_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If show_mnu = False Then Exit Sub
    If Button = vbLeftButton Then
        tmrResize.Enabled = False
        resize_down = False
    End If
End Sub

Private Sub tbMenu_ButtonClick(ByVal Button As MSComctlLib.Button)
    If Button.Key = "Shortcuts" Then
        frmShortcuts.show
        frmShortcuts.WindowState = vbMaximized
        frmShortcuts.SetFocus
    Else
        On Error Resume Next
        ActiveForm.CommandPass Button.Key
    End If
End Sub

Private Sub tmrResize_Timer()
    On Error Resume Next
    GetCursorPos cursor_pos
    picLeft.Width = (Me.Width - ((cursor_pos.X * Screen.TwipsPerPixelX) - Me.Left)) - 90
End Sub

Private Sub tmrMemStatus_Timer()
    Call GlobalMemoryStatus(MEM_STAT)
    lblPMem.Caption = Format((MEM_STAT.dwAvailPhys / 1024) / 1024, "#,##0.0") & " MB"
    lblVMem.Caption = Format((MEM_STAT.dwAvailVirtual / 1024) / 1024, "#,##0.0") & " MB"
End Sub

Public Sub UnloadChilds()
''Unload all active forms
    Dim Form As Form
    
    For Each Form In Forms
       ''Unload all active childs
       If Form.Name <> Me.Name And Form.Name <> "frmShortcuts" Then Unload Form
    Next Form
   
    Set Form = Nothing
End Sub

-Error on the bold area

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

my code

'Var for point api function
Dim cursor_pos As POINTAPI

Public CloseMe  As Boolean

Dim resize_down     As Boolean
Dim show_mnu        As Boolean
Dim pos_num         As Integer

Private Sub Command1_Click()

End Sub




Private Sub mnu_Old_Operation_Click()
frmRptOperationOld.show 1
End Sub


Private Sub MDIForm_Load()

    show
    Me.BackColor = &H80000005
    HideTBButton "", True
    frmShortcuts.show
    
'    Crystal report connection - use only 1 connection for all reports
    [B]CrystalReport0.Connect = "west.west.com.my" & ";UID=sa;PWD=123;DSQ=WMS_TEST;"[/B]

  
    frmLogin.show vbModal: If CloseMe = True Then Unload Me: Exit Sub: Exit Sub
    
    'Set the control properties
    Set lvWin.SmallIcons = i16x16
    Set lvWin.Icons = i16x16
    
    DisplayUserInfo
    
    lvWin.ListItems.Add(, "frmShortcuts", "@Shortcuts", 1, 1).Bold = True
    
    show_mnu = True
    show_menu (show_mnu)
    
    If Trim(CurrUser.USER_CATEGORY) <> "Supervisor" Then
        tbMenu.Buttons(6).Enabled = False
        mnu_AdditionalCharges.Visible = False
        mnu_AuditJob.Visible = False
    End If
   
  
End Sub




Private Sub MDIForm_Unload(Cancel As Integer)
    Set MAIN = Nothing
    If conn.State = adStateOpen Then
        conn.Close
    End If
End Sub

Private Sub mnuA_Click()
    frmAbout.show vbModal
End Sub

Private Sub mnuHKS_Click()
    'AddTest
End Sub

Private Sub picLeft_Resize()
    On Error Resume Next
    Frame1.Width = picLeft.ScaleWidth
    lvWin.Width = picLeft.ScaleWidth
    lvWin.Height = picLeft.ScaleHeight - lvWin.Top - 20
End Sub

Private Sub picSeparator_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If show_mnu = False Then Exit Sub
    If Button = vbLeftButton Then
        tmrResize.Enabled = True
        resize_down = True
    End If
End Sub

Private Sub picSeparator_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If show_mnu = False Then Exit Sub
    If Button = vbLeftButton Then
        tmrResize.Enabled = False
        resize_down = False
    End If
End Sub

Private Sub tbMenu_ButtonClick(ByVal Button As MSComctlLib.Button)
    If Button.Key = "Shortcuts" Then
        frmShortcuts.show
        frmShortcuts.WindowState = vbMaximized
        frmShortcuts.SetFocus
    Else
        On Error Resume Next
        ActiveForm.CommandPass Button.Key
    End If
End Sub

Private Sub tmrResize_Timer()
    On Error Resume Next
    GetCursorPos cursor_pos
    picLeft.Width = (Me.Width - ((cursor_pos.X * Screen.TwipsPerPixelX) - Me.Left)) - 90
End Sub

Private Sub tmrMemStatus_Timer()
    Call GlobalMemoryStatus(MEM_STAT)
    lblPMem.Caption = Format((MEM_STAT.dwAvailPhys / 1024) / 1024, "#,##0.0") & " MB"
    lblVMem.Caption = Format((MEM_STAT.dwAvailVirtual / 1024) / 1024, "#,##0.0") & " MB"
End Sub

Public Sub UnloadChilds()
''Unload all active forms
    Dim Form As Form
    
    For Each Form In Forms
       ''Unload all active childs
       If Form.Name <> Me.Name And Form.Name <> "frmShortcuts" Then Unload Form
    Next Form
   
    Set Form = Nothing
End Sub

-Error on the bold area

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

What is the DataType of CrystalReport0? Is that a control added at design time?
Just try to right click on the word "Connect" and click definition. If you get a message box showing "Identifier under cursor not recognized.", then the function is not a member of CrystalReport0.

This article has been dead for over six months. Start a new discussion instead.