Results 1 to 9 of 9

Thread: vba (vba)

  1. #1
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    vba (vba)

    How would I take a button that already exists (BTNhelp, this button fills in my textbox1 with the criteria from an area on page1 called HELPME. )
    and change it so that when my form is opened the textbox1 is automatically filled in with whatever is in the helpme area on page1. (another words no button command)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: vba (vba)

    Which VBA? Page1 of what? Is this Made2Manage again?

  3. #3
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: vba (vba)

    hi hans....
    no it's not made 2 manage this time... stricly VB6

    on my form I currently have it set up so that if the user clicks BTN Helpme it will incorporate what is on my front page in another textbox called HELP ME to textbox1 on my form.

    I need it so that when the user opens my form the textbox1 is already populated with whatever is in the help me textbox on page 1.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: vba (vba)

    You should be able to use the Form_Load event of the form to populate TextBox1.

  5. #5
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: vba (vba)

    that worked thanks....

    how would I code it if they click on the item actually inside the listbox to open. It wouldn't be another click event would it.

  6. #6
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: vba (vba)

    Yes, but it would seem that a double-click event would be a better choice
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  7. #7
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: vba (vba)

    Hans....

    strictly VBA now....

    within my listbox I try to click one item and it either does not open upon my first attempt or it opens twice.

    it seems that say if there were 5 items within my listbox, If i click on item 1 it does not open, I click on item 2 it opens, I click on item 3 it opens but items 4 and 5 do not open either. now if I refresh the listbox and have those same 5 items there and I first click on item 4 it opens but when I click on item 2 it does not.

    what am I doing wrong here.

    Option Explicit
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    (ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long

    Private Const LB_FINDSTRINGEXACT = &H1A2
    Private Const CB_FINDSTRINGEXACT = &H158
    Private Const SW_SHOWNORMAL = 1
    Private Const SW_SHOWMINIMIZED = 2
    Private Const SW_SHOWMAXIMIZED As Long = 3
    Public Function INIT() As Boolean
    Call btnok_click
    End Function
    Sub btnok_click()
    Dim strFile As String
    Dim strPath As String
    List1.Clear
    strFile = Dir("J:Eimg" & page1.txtfpartno.Value) & "*.*")
    Do While Not strFile = ""
    Me.List1.AddItem strFile
    strFile = Dir
    Loop
    End Sub
    Private Sub BtnExit_Click()
    End
    End Sub

    Private Sub lbl3_Click()
    Call btnok_click
    End Sub

    Private Sub list1_change()
    Dim strFile As String
    Dim lngResult As Long
    Dim strPath As String

    strFile = Dir("J:Eimg" & page1.txtfpartno.Value) & "*.*")
    lngResult = ShellExecute(0&, "Open", "J:Eimg" & Me.List1, 0&, 0&, CB_FINDSTRINGEXACT)

    If lngResult <= 32 Then
    MsgBox "Something went wrong.", vbExclamation
    End If
    End Sub


    Private Sub UserForm_Click()
    Call btnok_click
    End Sub


    P.S.

    Yes I'm using some of the previous code. But NO this is not MADE2MANAGE strickly VBA.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: vba (vba)

    1) The line

    strFile = Dir("J:Eimg" & page1.txtfpartno.Value) & "*.*")

    occurring twice in your code is not valid. It should be

    strFile = Dir("J:Eimg" & page1.txtfpartno.Value & "*.*")

    2) I don't understand why you use this line in list1_change - the variable strFile isn't used there.

    3) You shouldn't use CB_... constants in ShellExecute, they are for combo boxes. Use one of the SW_... constants instead.

    lngResult = ShellExecute(0&, "Open", "J:Eimg" & Me.List1, 0&, 0&, SW_SHOWMAXIMIZED)

    4) I wouldn't use the On Change event of the list box, but the On Dbl Click event, as already indicated by SammyB. Using On Change leaves no room for the user to correct a mistake.

  9. #9
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: vba (vba)

    thanks the showmaximized worked like a gem...

    you DA MAN!

Posting Permissions

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