Results 1 to 5 of 5

Thread: Package and Deployment Wizard

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2006
    Posts
    27

    Package and Deployment Wizard

    Hi all
    I am having problems with packaging my system to run on other machines. It all installs fine, and all the functions work apart from a find button. When I click this to find an employee, it lets me enter the name, retrieves the name but come up with a run time error 5 "Invalid call or procedure." Could someone help me please?

    Thanks

    Yus

  2. #2
    Junior Member
    Join Date
    Feb 2006
    Posts
    30

    Re: Package and Deployment Wizard

    There's nothing wrong with the package.

    Please check your code...

    Regards,
    Raman
    Last edited by Hack; Sep 7th, 2006 at 05:54 AM. Reason: Removed EMail address

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2006
    Posts
    27

    Re: Package and Deployment Wizard

    VB Code:
    1. Option Explicit
    2. Dim lTotalRecords As Long
    3.  
    4. Private Enum CmdButtons
    5. cmdMoveFirst = 0
    6. cmdMovePrevious = 1
    7. cmdMoveNext = 2
    8. cmdMoveLast = 3
    9. cmdAddNew = 4
    10. cmdEdit = 5
    11. cmdSave = 6
    12. cmdDelete = 7
    13. cmdUndo = 8
    14. cmdFind = 9
    15. cmdDone = 10
    16. End Enum
    17.  
    18.  
    19.  
    20.  
    21. Private Sub cmdButton_Click(Index As Integer)
    22. Static vMyBookMark As Variant
    23. Select Case Index
    24. Case cmdMoveFirst
    25.     Data1.Recordset.MoveFirst
    26.     Call updateButtons
    27. Case cmdMovePrevious
    28.     Data1.Recordset.MovePrevious
    29.     Call updateButtons
    30. Case cmdMoveNext
    31.     Data1.Recordset.MoveNext
    32.     Call updateButtons
    33. Case cmdMoveLast
    34.     Data1.Recordset.MoveLast
    35.     Call updateButtons
    36. Case cmdAddNew          '--add a new record
    37. With Data1.Recordset
    38.     If (.EditMode = dbEditNone) Then
    39.     If (lTotalRecords > 0) Then
    40.         vMyBookMark = .Bookmark
    41.         Else
    42.             vMyBookMark = ""
    43.         End If
    44.         .AddNew
    45.         Call updateButtons
    46.         lblRecordCount = "Adding New Record"
    47.         End If
    48.         End With
    49. Case cmdEdit            '--edit the current record
    50. With Data1.Recordset
    51.     If (.EditMode = dbEditNone) Then
    52.     vMyBookMark = .Bookmark
    53.     .Edit
    54.     Call updateButtons
    55.     lblRecordCount = "Editing"
    56.     End If
    57.     End With
    58.  
    59. Case cmdSave            '--save the current record
    60. Dim bMoveLast As Boolean
    61.     With Data1.Recordset
    62.         If (.EditMode <> dbEditNone) Then
    63.         If .EditMode = dbEditAdd Then
    64.         bMoveLast = True
    65.         Else
    66.         bMoveLast = False
    67.         End If
    68.         .Update
    69.         If (.EditMode = dbEditNone) Then
    70.         lTotalRecords = .RecordCount
    71.         If (bMoveLast = True) Then
    72.         .MoveLast
    73.         Else
    74.         .Move 0
    75.         End If
    76.         updateButtons True
    77.         End If
    78.         Else
    79.             .Move 0
    80.             End If
    81.             End With
    82. Case cmdDelete          '--delete the current record
    83. Dim iResponse As Integer
    84. Dim sAskUser As String
    85. sAskUser = "Are you sure you want to delete this record?"
    86. iResponse = MsgBox(sAskUser, vbQuestion + vbYesNo + _
    87.             vbDefaultButton2, "Personal Details Table")
    88.         If (iResponse = vbYes) Then
    89.             With Data1.Recordset
    90.             .Delete
    91.             lTotalRecords = .RecordCount
    92.             If (lTotalRecords > 0) Then
    93.             If lTotalRecords = 1 Then
    94.             .MoveFirst
    95.             ElseIf .BOF Then
    96.             .MovePrevious
    97.             End If
    98.             End If
    99.             End With
    100.             End If
    101.             Call updateButtons
    102. Case cmdUndo            '--undo changes to the current record
    103. With Data1.Recordset
    104.     If (.EditMode <> dbEditNone) Then
    105.         .CancelUpdate
    106.         If (Len(vMyBookMark)) Then
    107.         .Bookmark = vMyBookMark
    108.         End If
    109.         updateButtons True
    110.         Else
    111.         .Move 0
    112.         End If
    113.         End With
    114. Case cmdFind            '--find a specific record
    115. Dim iReturn As Integer
    116.     gFindString = ""
    117.    
    118.     With frmFind
    119.     .addCaption = "Type Employee Surname to find"
    120.     .recordSource = "SELECT EmployeeSurname FROM Bank"
    121.     .Show vbModal
    122.     End With
    123.    
    124.     If (Len(gFindString) > 0) Then
    125.     With Data1.Recordset
    126.         .FindFirst "EmployeeSurname = '" & gFindString & " ' "
    127.         If (.NoMatch) Then
    128.         iReturn = MsgBox("Employee Forename " & gFindString & _
    129.         " was not found.", vbCritical, "Personal")
    130.         Else
    131.         iReturn = MsgBox("Employee Name " & gFindString & _
    132.         " was retrieved.", vbInformation, "Personal")
    133.         End If
    134.         End With
    135.         End If
    136.         updateButtons
    137.        
    138. Case cmdDone            '--exit the form
    139.     Load FrmMenu
    140.     FrmMenu.Show
    141.    
    142.     Unload FrmRegistration2
    143. End Select
    144. End Sub
    145.  
    146. Private Sub Data1_Reposition()
    147. With Data1.Recordset
    148. lblRecordCount.Caption = "Bank Record " & (.AbsolutePosition + 1) & _
    149.                                 " of " & lTotalRecords
    150.                                 ProgressBar1.Value = .PercentPosition
    151.                 If (Combo1.Visible) Then Combo1.SetFocus
    152. End With
    153.  
    154.  
    155. End Sub
    156.  
    157. Private Sub Form_Activate()
    158.  
    159. With Data1.Recordset
    160.     .MoveLast
    161.     lTotalRecords = .RecordCount
    162.     .MoveFirst
    163.     End With
    164.    
    165.     updateButtons True
    166.    
    167. End Sub
    168.  
    169.  
    170. Public Sub updateButtons(Optional bLockEm As Variant)
    171.  
    172. '------------------------------------------------------------------------------------------------------
    173. '------------------------------------------------------------------------------------------------------
    174. 'Position   Button
    175. '   0       move first
    176. '   1       move previous
    177. '   2       move next
    178. '   3       move last
    179. '   4       add a new record
    180. '   5       edit the current record
    181. '   6       save the current record
    182. '   7       delete the current record
    183. '   8       undo any changes
    184. '   9       find a specific record
    185. '   10      done. Unload the form
    186. '--------------------------------------------------------------------------------------------------------
    187.  
    188. Select Case Data1.Recordset.EditMode
    189.  
    190. Case dbEditNone
    191. If (lTotalRecords > 1) Then
    192. If (Data1.Recordset.BOF) Or _
    193. (Data1.Recordset.AbsolutePosition = 0) Then
    194.     navigateButtons ("00111101011")
    195. ElseIf (Data1.Recordset.EOF) Or _
    196.     (Data1.Recordset.AbsolutePosition = lTotalRecords - 1) Then
    197.     navigateButtons ("11001101011")
    198.     Else
    199.     navigateButtons ("11111101011")
    200.     End If
    201.     ElseIf (lTotalRecords = 0) Then
    202.     navigateButtons ("0000100001")
    203.     End If
    204.     If (Not IsMissing(bLockEm)) Then
    205.     lockTheControls (bLockEm)
    206.     End If
    207.    
    208.     Case dbEditInProgress
    209.     Call lockTheControls(False)
    210.     Combo1.SetFocus
    211.     navigateButtons ("00000010100")
    212.     Case dbEditAdd
    213.     Call lockTheControls(False)
    214.     navigateButtons ("00000010100")
    215.     Combo1.SetFocus
    216. End Select
    217.  
    218. End Sub
    219.  
    220. Public Sub navigateButtons(sButtonString As String)
    221. '-------------------------------------------------------------------------------------------------------
    222. '-------------------------------------------------------------------------------------------------------
    223.  
    224. Dim iIndx As Integer
    225. Dim iButtonLength As Integer
    226.  
    227. sButtonString = Trim$(sButtonString)
    228. iButtonLength = Len(sButtonString)
    229.  
    230. For iIndx = 1 To iButtonLength
    231. If (Mid$(sButtonString, iIndx, 1) = "1") Then
    232. cmdButton(iIndx - 1).Enabled = True
    233. Else
    234. cmdButton(iIndx - 1).Enabled = False
    235. End If
    236. Next
    237.  
    238. DoEvents
    239.  
    240. End Sub
    241.  
    242. Public Sub lockTheControls(bLocked As Boolean)
    243.  
    244. Dim iIndx As Integer
    245.  
    246. With Screen.ActiveForm
    247. For iIndx = 0 To .Controls.Count - 1
    248.     If (.Controls(iIndx).Tag = "1") Then
    249.     If (TypeOf .Controls(iIndx) Is TextBox) Then
    250.     If (bLocked) Then
    251.     .Controls(iIndx).Locked = True
    252.     .Controls(iIndx).BackColor = vbWhite
    253.    
    254.     Else
    255.     .Controls(iIndx).Locked = False
    256.     .Controls(iIndx).BackColor = vbYellow
    257.     Text1(7).Locked = True
    258.     End If
    259.     End If
    260.     End If
    261.     Next
    262.     End With
    263.  
    264.  
    265. End Sub
    266.  
    267. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    268. Dim iMessage As Integer
    269.  
    270. If (Data1.Recordset.EditMode <> dbEditNone) Then
    271. iMessage = MsgBox("You must complete editing the current record", _
    272.                             vbInformation, "Bank Details")
    273.                            
    274.             Cancel = True
    275.         End If
    276.  
    277. End Sub
    278.  
    279.  
    280.  
    281. Public Sub highLight()
    282.  
    283. With Screen.ActiveForm
    284.     If (TypeOf .ActiveControl Is TextBox) Then
    285.     .ActiveControl.SelStart = 0
    286.     .ActiveControl.SelLength = Len(.ActiveControl)
    287.     End If
    288.     End With
    289. End Sub
    290.  
    291.  
    292.  
    293.  
    294. Private Sub mnuAbout_Click()
    295. Load FrmSplash2
    296. FrmSplash2.Show
    297. End Sub
    298.  
    299. Private Sub mnuexit_Click()
    300. Unload Me
    301. End Sub

    This is the code. I really cant see where I have gone wrong. When I run and compile it, it runs perfectly. Only when I install it through the package and deployment that the find button brings up that error message "runtime error 5". Im stuck mate.

    Regards

    Yus
    Last edited by si_the_geek; Sep 7th, 2006 at 08:14 AM. Reason: added vbcode tags

  4. #4
    Junior Member
    Join Date
    Feb 2006
    Posts
    30

    Re: Package and Deployment Wizard

    VB Code:
    1. Public Sub updateButtons(Optional bLockEm As Variant)
    2.     Select Case Data1.Recordset.EditMode
    3.         Case dbEditNone
    4.             If (lTotalRecords > 1) Then
    5.                 If (Data1.Recordset.BOF) Or _
    6.                     (Data1.Recordset.AbsolutePosition = 0) Then
    7.                     navigateButtons ("00111101011")
    8.                 ElseIf (Data1.Recordset.EOF) Or _
    9.                     (Data1.Recordset.AbsolutePosition = lTotalRecords - 1) Then
    10.                     navigateButtons ("11001101011")
    11.                 Else
    12.                     navigateButtons ("11111101011")
    13.                 End If
    14.             ElseIf (lTotalRecords = 0) Then
    15.                 navigateButtons ("0000100001")
    16.             End If
    17.             If (Not IsMissing(bLockEm)) Then
    18.                 lockTheControls (bLockEm)
    19.             End If
    20.         Case dbEditInProgress
    21.             Call lockTheControls(False)
    22.             Combo1.SetFocus
    23.             navigateButtons ("00000010100")
    24.         Case dbEditAdd
    25.             Call lockTheControls(False)
    26.             navigateButtons ("00000010100")
    27.             Combo1.SetFocus
    28.     End Select
    29. End Sub

    remove the line "Combo1.SetFocus" from this procedure and build the package again. Just give it a try...

    Regard,
    Raman
    Last edited by Hack; Sep 7th, 2006 at 05:54 AM. Reason: Removed EMail address

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Package and Deployment Wizard

    @Raman_xs:

    I have edited your posts and removed your email address.

    You should never post your email address in an open post on an open forum. Mail spam bots can pick that up and before you know it, your mailbox is full of junk mail. If you wish to share your email address with other forum members, please do so via our PM system.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width