Consulting

Page 1 of 3 1 2 3 LastLast
Results 1 to 20 of 58

Thread: Solved: Vba Newbie Require Help Please..

  1. #1

    Solved: Vba Newbie Require Help Please..

    Hi, I have started working with vba since monday. I have tried my best and got most of the interface out the way, and the coding is nearly finished aswell. The main problem i am facing at the moment, is when i select a button, the button takes me on the next page. I dont want this to happen, as on the first page there are 9 questions, all questions must be filled in, in order for the user to be taken to the second page. Sorry if you are not understanding me, I shall try to break it down.

    Question 1 - 2 radio buttons
    Question 2 - 1 combo box
    Question 3 - 2 text boxes
    Question 4 - 4 radio buttons
    Question 5 - 1 combo box
    Question 6 - 4 radio buttons
    Question 7 - 4 radio buttons
    Question 8 - 3 radio buttons, and
    Question 9 - 5 check boxes.

    What i need the program to do is, when the "Next" button is selected, it shall look at all of the values and if none of the value in a question are met, a message box should appear letting the user know.

    Thanks

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hi kaiser,
    Could you possibly post the document? Sanitized of any personal or proprietary info.
    It would make it much easier to help with your problem.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    kaiser,
    The main problem i am facing at the moment, is when i select a button, the button takes me on the next page.
    The problem is - WE are not facing it. We can't see over your shoulder at your screen.

    So...we have no idea:

    1. are these buttons on a userform (I think so, but...)?
    2. what "pages" are you talking about? Are these multi-pages on a userform? Pages in the document?
    3. if a button "takes" you to a "next page" then it has been told to do so. We can not figure this out unless we can see soemthing - preferably, as Steve mentions, an actual document. However, even posting relevant code will help a lot.

  4. #4

    www(dot)uploading(dot)com/files/21QFFQ67/Work(dot)doc(dot)html

    hope it helps

    were it says dot put in .

    as i cant post link as i have less than 5 posts

  5. #5
    I know im pushing it but once you download the file and look at the first userform, on the third question there is a help button, i have the following code for that button

    MsgBox ("1 Stone = 14 Pounds 1 Kg = 2.2 Pounds 1 Feet = 30 Centimetres 1 Inch = 2.5 Centimetres")

    the message box shows the information like in 1 complete line. Ive been going crazy for the past few days by trying to find the code that list the information in the message box for example

    1 Stone = 14 Pounds
    1 Kg = 2.2 Pounds
    1 Feet = 30 Centimetres
    1 Inch = 2.5 Centimetres

    instead of 1 Stone = 14 Pounds 1 Kg = 2.2 Pounds 1 Feet = 30 Centimetres 1 Inch = 2.5 Centimetres

  6. #6
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    No....that does not help. I don't see anything relevant. I tried replacing your (dot) with ".", but it just gave me a opening page for Uploadoing.com.

    Again...you are giving us text that does not really SAY anything. You need to be able to articulate what you are thinking. What was I supposed to see?

    Try answering questions.

    What "pages" are you talking about? Second page of what? The document? A multi-page userform?

  7. #7
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hi kaiser,
    Hit "Post Reply" at the bottom of the last thread....
    then click on manage attachments.
    You can post your actual document here on the forum...


    ps here is your work.doc from the link you provided
    see attached
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  8. #8
    im sorry but its not letting me do it as i have exceeded the forums limit.

    my file size is 70kb and there only letting me upload 20

  9. #9
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Slow down! Slow down!

    1. I still can not see anything yet.
    2. I see no file I can download.
    3. You have to learn to post explicit text.
    4. Try to keep your posts to one request. Your first post was "pages". Now you are posting about messagebox displays. Keep to what you ask in your first post...especially when you have not received an answer yet!

    However, as to your messagebox text - this is simple. You need to add a carriage return/line feed to your message string.[vba]MsgBox ("1 Stone = 14 Pounds" & vbCrLf & _
    "1 Kg = 2.2 Pounds" & vbCrLf & _
    "1 Feet = 30 Centimetres" & vbCrLf & _
    "1 Inch = 2.5 Centimetres")[/vba]vbCrLf is a built-in VBA instruction for Carriage return/Line feed.

    You had better look up some information on using strings.

  10. #10
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    You just have to zip it up.....
    Gerry, I think kaiser is looking for validation of fields filled out before moving to the second userform...kaiser, please verify
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  11. #11
    Im sorry if i have confused you people. In word i have 2 userforms 1 is knows as userform1 and the other is knows as userform2. I want to click on "next" in userform1 and this shall open the userform2 page. All the radiobuttons/comboboxes/text boxes and check boxes are in userform1.

    Hope that helps you

  12. #12
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Well, yes, I can see there is a request for validation.

    Second userform? What second userform? Things are happening very quickly here. I seem to be a post behind things.

    kaiser - validation is almost always a question of logic. Error trapping and validation is where (in a lot of cases) the most work goes. There are methods for good error trapping/validation, but the logic behind it - WHY this value is OK, but that value is not - has to come from you.

    Steve, your post seems to indicate you have a file. Yes? You mention "attached", but there is none.

  13. #13
    http://www.uploading.com/files/QG1S2372/Work.doc.html

    Should work now, i have other validations on the first form but this one seems a little bit tricky.

  14. #14
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hi Gerry,
    I posted his file for him in post #7 of this thread.....I can see it and am wondering if there is a problem with the forum????

    ps Gerry I edited the thread to add the attachment so you may have to refresh to see it...sorry.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  15. #15
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Darn, I still seem to be a wee bit behind. OK, confirmed - ther are two userforms. OK, so the logic for validation of the values on userform 1 needs to be done before userform 2 is displayed. That makes sense.

    So do it. You will need (probably) some IF statements

    If question 1 Button 1 selected then
    do this
    Else ' Button 2 selected
    do that
    End If

    Or some Select Case statements, say for Question 5 (the combobox with items "yaddayadda", "blahblah", "Yogi Bear", "Santa Claus"):[vba]Select Case ComboBox5.Value
    Case "yaddayadda"
    ' do whatever yaddayadda is supposed to mean to do
    Case "blah blah"
    ' do whatever blahblah is supposed to mean to do
    Case "Yogi Bear"
    ' do whatever Yogi Bear is supposed to mean to do
    Case "Santa Claus"
    ' do whatever Santa Claus is supposed to mean to do
    End Select[/vba]These are just logic statements - which is what validation is all about.

  16. #16
    I understand the Id and the Select Statements, But I just dont get how i could put everything together. For example I want it to check the first 2 Radio Buttons, AND then the next question which is a Combobox AND then the next question. Im asking this because at the moment if all fields are empty, and a radio button is selected in any random question the nex page will be shown when the button is clicked.

  17. #17
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    by next page you mean userform 2
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  18. #18
    Quote Originally Posted by lucas
    by next page you mean userform 2
    yup, i mean userform2

  19. #19
    i know if i can get the first question to work i shall be able to do the rest

    so far i have this

    If obmale.Value = False Then MsgBox ("Please Complete Question1")
    Else
    If obfemale.Value = False Then MsgBox ("Please Complete Question1")
    End If

    but it keeps throwin errors, any help please?

  20. #20
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Crap crap crap. Behind STILL!

    OK, I have the file, but I am going to drop out of this thread. The userform is so large that it will not fit on my screen. The buttons are not visible at all, and there is no way to scroll to see them. This is poor design. Fortunately I always step into any stranger's code, so I could get out.

    I could resize your form so I can see/use it, but frankly, I don't have the time to do that.

    Why do you have the userform so big????? It may be OK on your system, but it is NOT reasonable to assume everyone will have the same screen resolution as you. I don't, and because of that, your userform is - even as it is - totally useless for me. I can't click the ReSet or Continue button, even if I wanted to. They are not visible on my screen. I can of course see them in the VBE, but that is hardly the point.

    WHY are you using all those frames? I can use the use of most of them, but WHY are you putting textboxes in them to explain what to do? You can use the .Caption property of the frame to do this.

    You are taking up a HUGE amount of real estate for this form.

    Plus, a multipage would be a much better way of getting all these questions on a userform.

    As for your validation - again, you have to build up the whole logic.

Posting Permissions

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