Consulting

Page 1 of 2 1 2 LastLast
Results 1 to 20 of 25

Thread: Solved: linking userforms

  1. #1

    Solved: linking userforms

    hi
    i have a text box with a list of numbers in it, i woud like to select a number from the list and the link it to another textbox in userform.
    so if i select 01 in the combo box then i want new user form to have a text box that displays 01
    thanks ash

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Launch the userform from the first, and just reference that property

    Userform1.ComboBox1.Value
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    i have 4 option buttons in userform1 and which ever one is selected with then open its relevent userform2/3/4/5
    so do i set it to
    if
    option button 1 = true then. userform1.show?

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Yep.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    thank you one more question, i have a userform with an txt box with id numbers that realte to data in a sheet, i want the userform to input data i add to the correct row. so if the number is 1001 i need it to enter the details on the row that has 1001 in column 1

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Just find the row number

    [vba]
    rownum = Application.Match(Me.TextBox1.Text, Worksheets("Sheet1").Columns("I"),0)[/vba]

    and use that row to populate other cells

    [vba]
    With Worksheets("Sheet1")

    .Cells(rownum, "A").Value = "some value"
    .Cells(rownum, "B").Value = "another value"
    'etc.
    End With[/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    here is the code i have used
    [vba]Private Sub cmdEnter_Click()
    rownum = Application.Match(Me.txteditjobNumber.Text, Worksheets("JobList").Columns("B"), 0)
    'copy the data to the database
    With Worksheets("joblist")
    .Cells(rownum, "C").Value = txteditcustomernumber
    .Cells(rownum, "D").Value = txteditcustomername
    'etc.
    End With
    'close The Form
    Unload Me
    End Sub
    [/vba] but comes up with a error 13 type mismatch
    Last edited by Aussiebear; 04-12-2012 at 03:10 PM. Reason: Added vba tags to code

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Where is the error?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    Cells(rownum, "C").Value = txteditcustomernumber

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Do you know what the value of rownum is? Are the text box names correct?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  11. #11
    yeh the text box names are correct,
    i have in column B the job numbers starting at 12001 and going to 12008 at the moment (job numbers will increase) and then in columns c,d,e ect are the details of that job, customer name, address number ect ect.

  12. #12
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Then I am at a loss. Can you post the workbook?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  13. #13
    what does the 0 represent at the end of this code?
    rownum = Application.Match(Me.txteditjobNumber.Text, Worksheets("JobList").Columns("B"), 0)

  14. #14
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It just means look for an exact match.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  15. #15
    ok could it be to do with where the data is stored in worksheet?
    as row 1 is empty, row 2 is a header and the data starts in row 3. column A is empty, column B is the job number columns C,D,E ect have the data in them corrosponding to the job jumber.

  16. #16
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    All this we could see if you would kindly post a sample workbook?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  17. #17
    i will post a sample workbbok shortly.
    thank you

  18. #18
    here is a small sample sheet
    Attached Files Attached Files

  19. #19
    did the sample woorkbook help and make sense?

  20. #20
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    993
    Location
    Excel is treating the Job# as numbers and in the Match you are passing the userform field which is a string.

    Convert the field to a number.

    [VBA]rownum = Application.Match(CInt(Me.txteditjobNumber.Value), Worksheets("JobList").Columns("B"), 0)[/VBA]

    You probably should have an error trap checking for this.

    (Bob, even if I change the format of the column to text, the match still can't find it. Is this normal?)

    David


Posting Permissions

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