Page 3 of 4 FirstFirst 1234 LastLast
Results 81 to 120 of 144

Thread: [RESOLVED] Runtime error '91': Object variable or with block not set

  1. #81

  2. #82

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Ok. Here it comes. Comments are welcome. Please confirm you have the updated file cz can be messy when you have a lot of file with similar name. Cheers
    Attached Files Attached Files

  3. #83

  4. #84
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Okay this should give you stuff to work on. Attach the project again when you are satisfied with it.

    1 In CPSystems you have Me.MousePointer = vbHourglass followed immediately by Me.MousePointer = vbNormal. If there was some long-running code between them then it would make sense to use them but as it is now it does noting for you.
    2 IMO the text on cpsystems is too large. Also it should say "…15589 Parts 1 and 2" or "…15589 Part 1 and Part 2"
    3 The CPSystems.Show line isn't necessary
    4 Using the menu of CPSystems I can open the onshore and offshore forms at the same time. Do you want that?
    5 I can't move the CPSystems form using the mouse. Why is that?
    6 You should add the following code to CPSystems to ensure that all forms are closed when you exit this form
    Code:
    Private Sub Form_Unload(Cancel As Integer)
    Dim frm As Form
    
    For Each frm In Forms
       Unload frm
       Set frm = Nothing
    Next
    End Sub
    7 When you tab through the fields on offshorecpsystems (which I'll refer to here from now on as offshore) and you tab out of cmdcancelform, the frame for the bracelet anode shows up which is something that you probably don't want to have happen.
    8 In offshore you have MsgBox "Please make a selection" for an empty textbox. While that's a good message for a combobox you should probably change it to MsgBox "Please enter a numeric value". You also have MsgBox "You must enter numeric value". I think something like MsgBox "Please enter a numeric value" would be better.
    9 I can put values like 99999999 and -1 in the textboxes. Is that valid? If there are valid ranges you should validate such textboxes for the range. You can do that in the Lost_Focus event of the textbox. If there is no specific range you might want to check for reasonable values. For example while a pipe could be 99999999 meters long, that's probably not reasonable so you should ask an "Are you sure?" type question
    10 In offshore and onshore you have a series of 3 Msgboxes that begin with "Prepare Plans and Specification". I, After a while using the app I would be annoyed at having to see and respond to those 3 messages every time I did a calculation. You could do something like the following instead. There is also a way to have a 'don't show this message again' option. If you're interested and need help with that let me know.

    Code:
    MsgBox "1. Prepare Plans and Specification" & vbCrLf & vbCrLf _
            & "2. Print Record" & vbCrLf & vbCrLf _
            & "3. Exit Program"
    11 When you have the same code in two or more forms it's a good idea to create one Public Sub in a module and call that sub instead of having to maintain duplicate code.
    12 What are you trying to say with "Select Alternative Cathodic Protection System"?
    13 Do you really need to tell the user to "Exit Program"?
    14 What are you trying to tell the user with "Select Alternative Cathodic Protection System"
    15 For my own information, how do you tell if this "Is this the most economical alternative?"

  5. #85
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    I just printed the output of the calculations and there are a few problems.

    The printing doesn't start until the form is closed and you have some unneeded code so instead of
    Code:
    Private Sub cmdPrint_Click()
    Dim Response As Integer
    Response = MsgBox("Ensure Printer is switched on and raedy. Click OK when you are ready", vbInformation + vbOKCancel, App.Title)
    If (Response = vbOK) Then
    Me.PrintForm
    Else
    End If
    End Sub
    You could do

    Code:
    Private Sub cmdPrint_Click()
    If vbokay = MsgBox("Ensure Printer is switched on and ready. Click OK when you are ready", vbInformation + vbOKCancel, App.Title) Then
        Me.PrintForm
        Printer.EndDoc
    End If
    End Sub
    The above corrects a typo where you had 'ready' typed as 'raedy'.
    The EndDoc causes the printing to happen immediately.

    There are still 2 problems however:
    When you do me.PrintForm the user isn't given the chance to choose the output printer if there are more than one, and the right side of the form is cut off in the output. To solve this I would create a report using Printer.Print and show the label captions and text values etcetera in a formatted fashion.

  6. #86

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Hi MartinLiss, you spoke my mind. Point #9:I think two of the text boxes will be taking negative values and setting the range for valid values is way over my head right now. Point #10: That was a big relief cz I was also getting bored seeing those msgs turn up, thanks but is got a problem with the If statement. It gives an error and didn't work with the else statement either. Would love to experiment the 'don't show this message again' option. Could you please help with a clue, thanks? Point #11: I think this point can wait after I hand this thing cz deadline is catching up with me. Point #12 and #14 is like a loop, couldn't get a code and figured a way out in my own terms? Point #13 and #15: has to do with the cost analysis for the life cycle of protecting the pipeline. See reference.
    Attached Images Attached Images

  7. #87

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Please help out how to resolve those two prroblems, can't think right now. Thanks

  8. #88

  9. #89

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    I will love to experiment with point #4 if both forms won't pose a nuisance on the screen. Point #5: the user is restricted toying with the mother form. What do you think?

  10. #90

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Ok. Post #85 I think.

  11. #91
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Here is one tutorial that you could use. You would do Printer.Print rather than just Print.

    And the error you are getting is because my vbOkay should be vbOK.

  12. #92

  13. #93

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    My reference was to the below code:
    Code:
    MsgBox "1. Prepare Plans and Specification" & vbCrLf & vbCrLf _
            & "2. Print Record" & vbCrLf & vbCrLf _
            & "3. Exit Program"

  14. #94

  15. #95

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    I meant like this:
    Code:
     If MsgBox "1. Prepare Plans and Specification" & vbCrLf & vbCrLf _
            & "2. Print Record" & vbCrLf & vbCrLf _
            & "3. Exit Program"
        Else
            'MsgBox "Select Alternative Cathodic Protection System"
    gives an error
    Please could you help with what's wrong here:
    vb Code:
    1. Printer.Print "Unit Surface Area"; Tab(20); frmcpcalculatedoutput.lblunitsurfac.Caption = unitsurface
    . Is giving "False" at the output which I believe the output form does not capture the values during print time. How do I declare the outputs public to be seen by the print command? Thanks for the load of information, my brain is swelled right now.

  16. #96

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Can I use the If statement to skip a line from printing which does not appear on the output form and how?, thanks

  17. #97
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Quote Originally Posted by Ehwenomare View Post
    I meant like this:
    Code:
     If MsgBox "1. Prepare Plans and Specification" & vbCrLf & vbCrLf _
            & "2. Print Record" & vbCrLf & vbCrLf _
            & "3. Exit Program"
        Else
            'MsgBox "Select Alternative Cathodic Protection System"
    gives an error
    Please could you help with what's wrong here:
    vb Code:
    1. Printer.Print "Unit Surface Area"; Tab(20); frmcpcalculatedoutput.lblunitsurfac.Caption = unitsurface
    . Is giving "False" at the output which I believe the output form does not capture the values during print time. How do I declare the outputs public to be seen by the print command? Thanks for the load of information, my brain is swelled right now.
    You would need to create Public variables in a code module. My suggestion at this point if you can get away with it is to use PrintForm for now and fix it later.

  18. #98
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Code:
     If vbOK = MsgBox("1. Prepare Plans and Specification" & vbCrLf & vbCrLf _
            & "2. Print Record" & vbCrLf & vbCrLf _
            & "3. Exit Program") Then
            ' do something
        Else
            'MsgBox "Select Alternative Cathodic Protection System"
    End If

  19. #99

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Thank you MartinLiss, No going back now cz I have edited the whole thing. I'll find a way to figure it out. How much will this app be valued in the market? lol, kidding anyway. Thanks for putting professional touch on my app. Pray that examiner never give me anything less than a distinction else I will mad cz your touch. It looks so pro. Thanks

  20. #100
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Perhaps for future reference, here's a project that allows the user to stop showing a form. You could use it now to show the 'annoying' messages. One thing that's missing is a way for the user to start showing the form again but that could be taken care of with a menu item.
    Attached Files Attached Files

  21. #101

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    The project file got's a problem. The highlighted line is not defined; expecting a function or Sub.
    vb Code:
    1. GetPrivateProfileString

  22. #102

  23. #103

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    What you were to pass across those it relate to the below code
    Code:
    If vbYes = MsgBox("1.Is this the most economical alternative?" & vbCrLf & vbCrLf _
            & "2. Prepare Plans and Specification" & vbCrLf & vbCrLf _
            & "3. Print Record" & vbCrLf & vbCrLf _
            & "4. Exit Program", vbQuestion + vbYesNo, "Confirm") Then
            ' do something
        Else
            If vbYes = MsgBox("Select Alternative Cathodic Protection System", vbQuestion + vbYesNo, "Confirm") Then
               If (cbocpstype.Text = "Impressed Current") Then
                   Call ImpressedCurrent
                    FrameImpressedCurrent.Visible = True
                    FrameSacrificialCurrent.Visible = False
                    frmcpcalculatedoutput.frameImpressedCurrentCP.Visible = True
                    frmcpcalculatedoutput.frmSacrificial.Visible = False
            Else
                    Call SacrificialCurrent
                    FrameImpressedCurrent.Visible = False
                    FrameSacrificialCurrent.Visible = True
                    frmcpcalculatedoutput.lblrecvolt.Visible = False
                    frmcpcalculatedoutput.lbl21.Visible = False
                    frmcpcalculatedoutput.lblreceff.Visible = False
                    frmcpcalculatedoutput.lbl15.Visible = False
                    frmcpcalculatedoutput.Label9.Visible = False
                    frmcpcalculatedoutput.Label7.Visible = False
                    frmcpcalculatedoutput.frameImpressedCurrentCP.Visible = False
                    frmcpcalculatedoutput.frmSacrificial.Visible = True
                    End If
    End If
    End If
    I have edited the code a bit and here's what I want the code to do for me but after the second else statement the code is not executed to display the command. Is there a way to go round it?

  24. #104

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    That was lovely. I can see how you'r just toying with the whole thing.
    Last edited by Ehwenomare; Jul 28th, 2011 at 05:23 PM. Reason: error

  25. #105

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    That code is complex to digest. Hard for a NB

  26. #106

  27. #107
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Quote Originally Posted by Ehwenomare View Post
    That code is complex to digest. Hard for a NB
    I probably should have included more comments. If you have questions I'll be happy to answer.

  28. #108

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    I'm not gonna tried that path now but maybe later, after the deadline the the questions will start rolling in.

  29. #109

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    That command should do the loop thing. When I click the msgBox button to say Yes it should display the frame I want on my input button without having to do a click event on the input form, how do I go about that?

  30. #110
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Quote Originally Posted by Ehwenomare View Post
    That command should do the loop thing. When I click the msgBox button to say Yes it should display the frame I want on my input button without having to do a click event on the input form, how do I go about that?
    We had a similar problem with a combobox and the solution was replacing it with a pair of option buttons. Would that work here?

  31. #111

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    No. I mean at run time. After inputting my values lets say for "Impressed Current" and I click the execute button, now I am not satisfied with the output results and I want to calculate values for the "Sacrificial current" without having to do a click event for the frame of sacrificial to be displayed at run time. I mean displaying automatically when it's not economically visible for me to embark on a project to design my system using Impressed current.

  32. #112
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    In the place where you ask if the user is satisfied and he isn't then you can do anything you want with the data input form. If you want to directly execute a Click event of one form from another form via code you would need to change the event from Private to Public and also reference the form. For example

    'From Form2
    Call Form1.Command1_Click

  33. #113

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Thank you MartinLiss, I'm done. That's not gonna happen with this project. I'm deleting that sick code. I think this your code could just solve my printing problem if i declare my execute command as public and i do the calling in the print statement. What do you think?
    vb Code:
    1. Call Form1.Command1_Click

  34. #114
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Quote Originally Posted by MartinLiss View Post
    In the place where you ask if the user is satisfied and he isn't then you can do anything you want with the data input form. If you want to directly execute a Click event of one form from another form via code you would need to change the event from Private to Public and also reference the form. For example

    'From Form2
    Call Form1.Command1_Click
    In the above when I said to make it Public I was referring to the Click event on say offshorecpsystems.

  35. #115

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    In the welcome screen I used a Font size:65 and you said it is too big, what size should I use?

  36. #116
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Quote Originally Posted by Ehwenomare View Post
    In the welcome screen I used a Font size:65 and you said it is too big, what size should I use?
    Up to you, but since it is displayed all the time I get tired of seeing the text 'screaming' at me.

    Another way around the problem would be to hide the CPSystems form after the user makes a selection and show it again when you unload your other forms.

  37. #117

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Ok i get it. Maybe my brain is getting tired and needs some rest.

  38. #118
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Quote Originally Posted by Ehwenomare View Post
    Ok i get it. Maybe my brain is getting tired and needs some rest.
    I bet you're tired. I'm tired and you've been up a lot longer than me.

  39. #119

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    lol, that's funny

  40. #120

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    O yeah, just got a lot do before the deadline catches up with me. It's barely a week today.

Page 3 of 4 FirstFirst 1234 LastLast

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