Results 1 to 4 of 4
  1. #1
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156

    Code problem

    I have a code that is kinda and kind not working.<br>


    <br>
    <br>
    This is the code. It is a log in form code. The problem is with the Sleep 100 and the Sleep 500 and the Sleep 25. parts of the codes. I have to change this part of the code to 'Sleep 100 and the 'Sleep 500 and the 'Sleep 25 and make them neutral and the code sorta kinda works.. If I don't I get a "Compile error" "Sub or function not defines" It has be baffeled. Thank-you Cheeco<br>
    <br>
    <br>
    Code:
    ' ***********************************************************<br>
    ' &nbsp; Form: frm_main<br>
    '<br>
    ' &nbsp; Function : &nbsp;login screen<br>
    '<br>
    ' &nbsp; Date last Modified : 26/02/2007<br>
    ' &nbsp; 26/02/2007 - redesign for Sydney use. Sydney's menu now in a<br>
    ' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;switchboard format<br>
    '<br>
    ' ***********************************************************<br>
    Option Compare Database<br>
    Option Explicit<br>
    ' ******************************************************<br>
    ' close form<br>
    ' ******************************************************<br>
    Private Sub close_form_Click()<br>
    On Error GoTo err_close_form_Click<br>
    &nbsp;&nbsp; &nbsp;<br>
    &nbsp;&nbsp; &nbsp;DoCmd.RunMacro "macro_exit"<br>
    exit_close_form_Click:<br>
    &nbsp;&nbsp; &nbsp;Exit Sub<br>
    err_close_form_Click:<br>
    &nbsp;&nbsp; &nbsp;MsgBox Err.Description<br>
    &nbsp;&nbsp; &nbsp;Resume exit_close_form_Click<br>
    End Sub<br>
    ' ***********************************************************<br>
    ' &nbsp; User has entered user_id and Password<br>
    ' ***********************************************************<br>
    Private Sub cmdOK_Click()<br>
    <br>
    &nbsp;&nbsp; &nbsp;Dim rst As DAO.Recordset<br>
    &nbsp;&nbsp; &nbsp;Dim rstV As Recordset<br>
    &nbsp;&nbsp; &nbsp;Dim stDocName As String<br>
    &nbsp;&nbsp; &nbsp;Dim stLinkCriteria As String<br>
    &nbsp;&nbsp; &nbsp;Dim i As Integer<br>
    &nbsp;&nbsp; &nbsp;Dim oPF As TSC_PF_Simple<br>
    &nbsp;&nbsp; &nbsp;Dim s As Object<br>
    &nbsp;&nbsp; &nbsp;Set oPF = New TSC_PF_Simple<br>
    &nbsp;&nbsp; &nbsp;Set s = CreateObject("SAPI.SpVoice")<br>
    &nbsp;<br>
    &nbsp;Set s = CreateObject("SAPI.SpVoice")<br>
    &nbsp;s.SPEAK "Good morning Susan. How are you today? Please wait while your database is being prepared for you."<br>
    &nbsp;Set s = Nothing<br>
    &nbsp;<br>
    &nbsp;&nbsp;'Init progress form<br>
    &nbsp;&nbsp; &nbsp; &nbsp;<br>
    &nbsp;&nbsp; <br>
    &nbsp;&nbsp; 'Show the form<br>
    &nbsp;&nbsp; &nbsp; &nbsp;oPF.Title = "Importing Objects" &amp; vbNewLine &amp; "Please wait..."<br>
    &nbsp;&nbsp; &nbsp; &nbsp;oPF.UpdateTask 0, "Preparing Import"<br>
    &nbsp;&nbsp; &nbsp; &nbsp;oPF.Show<br>
    &nbsp;&nbsp; &nbsp; &nbsp;<br>
    &nbsp;&nbsp; 'Since this is just a demo, I simulate a series of slow tasks by using the sleep<br>
    &nbsp;&nbsp; &nbsp; &nbsp;oPF.UpdateTask 0, "Importing forms: " &amp; vbNewLine &amp; 1 &amp; " of 10"<br>
    &nbsp;&nbsp; &nbsp; &nbsp;For i = 1 To 10<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; Sleep 100<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; oPF.UpdateTask i / 10, "Importing forms: " &amp; vbNewLine &amp; i &amp; " of 10"<br>
    &nbsp;&nbsp; &nbsp; &nbsp;Next<br>
    &nbsp;&nbsp; <br>
    &nbsp;&nbsp; <br>
    &nbsp;&nbsp; 'The progress form allows the user to cancel a running process, however, not that<br>
    &nbsp;&nbsp; 'the cancel is only reacted to when the progress form is updated.<br>
    &nbsp;&nbsp; &nbsp; &nbsp;<br>
    &nbsp;&nbsp; 'If you want to allow the user the possibility to cancel, set the Allowcancel property to true<br>
    &nbsp;&nbsp; 'If user cancels an an error 8101 is raised.<br>
    &nbsp;&nbsp; &nbsp; &nbsp;'oPF.AllowCancel = True<br>
    &nbsp;&nbsp; <br>
    &nbsp;&nbsp; 'Simulate another task running<br>
    &nbsp;&nbsp; &nbsp; &nbsp;oPF.UpdateTask 0, "Importing Queries:" &amp; vbNewLine &amp; "1 of 10"<br>
    &nbsp;&nbsp; &nbsp; &nbsp;For i = 1 To 5<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; 'Sleep 500<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; oPF.UpdateTask i / 5, "Importing Queries:" &amp; vbNewLine &amp; i &amp; " of 10"<br>
    &nbsp;&nbsp; &nbsp; &nbsp;Next<br>
    &nbsp;&nbsp; <br>
    &nbsp;&nbsp; 'Simulate a third task running, but now disallow cancel for this part<br>
    &nbsp;&nbsp; &nbsp; &nbsp;'oPF.AllowCancel = False<br>
    &nbsp;&nbsp; &nbsp; &nbsp;'Also change the titel. Note how the form expands to accomodate the long text<br>
    &nbsp;&nbsp; &nbsp; &nbsp;oPF.Title = oPF.Title &amp; vbNewLine &amp; "Do not turn of or unplug your device at this point"<br>
    &nbsp;&nbsp; <br>
    &nbsp;&nbsp; &nbsp; &nbsp;oPF.UpdateTask 0, "Importing tables:" &amp; vbNewLine &amp; "0 of 100"<br>
    &nbsp;&nbsp; &nbsp; &nbsp;For i = 1 To 100<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; 'Sleep 25<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; oPF.UpdateTask i / 100, "Importing tables:" &amp; vbNewLine &amp; i &amp; " of 100"<br>
    &nbsp;&nbsp; &nbsp; &nbsp;Next<br>
    &nbsp;&nbsp; &nbsp; &nbsp;<br>
    &nbsp;&nbsp; &nbsp; &nbsp;'Update title before closure. Note how the built in close delay gives just<br>
    &nbsp;&nbsp; &nbsp; &nbsp;'enough time for the user to see this message.<br>
    &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; oPF.Title = "Succes" &amp; vbNewLine &amp; "All Done"<br>
    &nbsp;&nbsp; &nbsp; &nbsp;<br>
    &nbsp;&nbsp; 'This code provide the greating message<br>
    &nbsp;&nbsp;<br>
    &nbsp;Set s = CreateObject("SAPI.SpVoice")<br>
    &nbsp;s.SPEAK "You may now proceed. and have a good day."<br>
    &nbsp;Set s = Nothing<br>
    &nbsp;&nbsp; <br>
    <br>
    Exit_Sub:<br>
    &nbsp;&nbsp; &nbsp;' Validate User ID and Password and then display menu items<br>
    &nbsp;&nbsp; &nbsp; &nbsp;display_menu<br>
    &nbsp;<br>
    Exit_cmdOK_Click:<br>
    &nbsp;&nbsp; &nbsp;Exit Sub<br>
    Err_cmdOK_Click:<br>
    &nbsp;&nbsp; &nbsp;MsgBox Err.Description<br>
    &nbsp;&nbsp; &nbsp;Resume Exit_cmdOK_Click<br>
    End Sub<br>
    <br>
    ' ******************************************************<br>
    ' relink database<br>
    ' the user can relink the database by click on the word Password<br>
    ' on the main menu<br>
    ' ******************************************************<br>
    Private Sub database_relink_Click()<br>
    On Error GoTo Err_database_relink_Click<br>
    &nbsp;&nbsp; &nbsp;DoCmd.OpenForm "frm_relink"<br>
    &nbsp;&nbsp; &nbsp;<br>
    Exit_database_relink_Click:<br>
    &nbsp;&nbsp; &nbsp;Exit Sub<br>
    Err_database_relink_Click:<br>
    &nbsp;&nbsp; &nbsp;MsgBox Err.Description<br>
    &nbsp;&nbsp; &nbsp;Resume Exit_database_relink_Click<br>
    End Sub<br>
    ' ******************************************************<br>
    ' maximizee the screen<br>
    ' ******************************************************<br>
    Private Sub Form_Load()<br>
    On Error GoTo Err_Form_Load<br>
    &nbsp;&nbsp; &nbsp;DoCmd.Maximize<br>
    Exit_Form_Load:<br>
    &nbsp;&nbsp; &nbsp;Exit Sub<br>
    Err_Form_Load:<br>
    &nbsp;&nbsp; &nbsp;MsgBox Err.Description<br>
    &nbsp;&nbsp; &nbsp;Resume Exit_Form_Load<br>
    &nbsp;&nbsp; &nbsp;<br>
    End Sub<br>
    Private Sub Form_Open(Cancel As Integer)<br>
    End Sub<br>
    ' ****************************************************************<br>
    ' when the user id gets the focus, the user id and password are reset to blank<br>
    ' ****************************************************************<br>
    Private Sub user_id_GotFocus()<br>
    On Error GoTo Err_user_id_GotFocus<br>
    &nbsp;&nbsp; &nbsp;'remove current user and password<br>
    &nbsp;&nbsp; &nbsp;Me!user_id = Null<br>
    &nbsp;&nbsp; &nbsp;Me!password = Null<br>
    &nbsp;&nbsp; &nbsp;<br>
    Exit_user_id_GotFocus:<br>
    &nbsp;&nbsp; &nbsp;Exit Sub<br>
    Err_user_id_GotFocus:<br>
    &nbsp;&nbsp; &nbsp;MsgBox Err.Description<br>
    &nbsp;&nbsp; &nbsp;Resume Exit_user_id_GotFocus<br>
    End Sub<br>
    <br>

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    It's really hard to read as HTML.
    can you paste it as text?

  3. #3
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    Thanks ranman256. I did figure it out. I hade to add this line of code

    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

    Now it is working fine.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    That was my first guess (I dumped all the gibberish into a notepad file and saved as .htm).
    Also, you have two set statements for the same thing: Set s = CreateObject("SAPI.SpVoice")
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Problem with code.
    By gstylianou in forum Access
    Replies: 3
    Last Post: 09-10-2014, 05:15 PM
  2. Code problem
    By sboelitz in forum Programming
    Replies: 1
    Last Post: 06-15-2012, 08:35 AM
  3. Problem with Code
    By jackiea in forum Programming
    Replies: 1
    Last Post: 10-07-2011, 05:59 PM
  4. Code Problem
    By Jeddell in forum Programming
    Replies: 2
    Last Post: 09-29-2011, 06:31 PM
  5. Problem with Code
    By cujee75 in forum Programming
    Replies: 0
    Last Post: 03-10-2006, 02:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums