VB 6.0 - VBA userform search sheet to form - update form - post back to sheet. need guidance.

Asked By Donald Ross on 15-Aug-15 06:54 PM

' this sub works only with the last name search, I can't seems to get it to work with the last (and, or) the first name.
' incase there are to contacts with the same last name.
' would consider adding a scroll button to the form so after the search I could simple scroll up or down from that position.

' Button 1

Sub CBSearch1_Click()

    Dim ws3 As Worksheet
    Set ws3 = ThisWorkbook.Sheets("Release form")
   
   row_number = 0
    Do
    DoEvents

    row_number = row_number + 1

    last_name = Sheets("Waivers").Range("A" & row_number)
    First_Name = Sheets("Waivers").Range("B" & row_number)
   
 If LCase(last_name) = LCase(TextBox1.Text) Then
' If LCase(Last_Name & "," & First_Name) = LCase(TextBox1.Text & "," & TextBox2.Text) Then

   TextBox1.Text = Sheets("Waivers").Range("a" & row_number)
   TextBox2.Text = Sheets("Waivers").Range("b" & row_number)
   TextBox3.Text = Sheets("Waivers").Range("c" & row_number)
   TextBox4.Text = Sheets("Waivers").Range("d" & row_number)
   TextBox5.Text = Sheets("Waivers").Range("e" & row_number)
   TextBox6.Text = Sheets("Waivers").Range("f" & row_number)
   TextBox7.Text = Sheets("Waivers").Range("g" & row_number)
   TextBox8.Text = Sheets("Waivers").Range("h" & row_number)
   TextBox9.Text = Sheets("Waivers").Range("i" & row_number)
   TextBox10.Text = Sheets("Waivers").Range("k" & row_number)
   
   
 
 End If
  
Loop Until last_name = ""
   

End Sub

' Button 2
' This Sub works as well

Sub CBrelease1_click()
   
    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
    Dim ws3 As Worksheet
    Set ws1 = ThisWorkbook.Sheets("Sign In")
    Set ws2 = ThisWorkbook.Sheets("Waivers")
    Set ws3 = ThisWorkbook.Sheets("Release form")
   
    ws3.Range("a17").Value = TextBox1.Text
    ws3.Range("L1").Value = TextBox1.Text
    ws3.Range("d17").Value = TextBox2.Text
    ws3.Range("a19").Value = TextBox3.Text
    ws3.Range("a21").Value = TextBox4.Text
    ws3.Range("d21").Value = TextBox5.Text
    ws3.Range("e21").Value = TextBox6.Text
    ws3.Range("i17").Value = TextBox7.Text
    ws3.Range("i19").Value = TextBox8.Text
    ws3.Range("i21").Value = TextBox9.Text
   
    ' rem'd out for testing & waisting paper
    ' ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
   '   IgnorePrintAreas:=False
   
   
    ' probably a better way to clear contents after print.
   
    ws3.Range("a17").Value = ""
    ws3.Range("L1").Value = ""
    ws3.Range("d17").Value = ""
    ws3.Range("a19").Value = ""
    ws3.Range("a21").Value = ""
    ws3.Range("d21").Value = ""
    ws3.Range("e21").Value = ""
    ws3.Range("i17").Value = ""
    ws3.Range("i19").Value = ""
    ws3.Range("i21").Value = ""
    
    Unload Me
   
    CheckInForm1.Show
   
   
End Sub

' Button 3

Sub Update_hunter1_Click()

'   TextBox1.Text = Sheets("Waivers").Range("a" & row_number)
'   TextBox2.Text = Sheets("Waivers").Range("b" & row_number)
'   TextBox3.Text = Sheets("Waivers").Range("c" & row_number)
'   TextBox4.Text = Sheets("Waivers").Range("d" & row_number)
'   TextBox5.Text = Sheets("Waivers").Range("e" & row_number)
'   TextBox6.Text = Sheets("Waivers").Range("f" & row_number)
'   TextBox7.Text = Sheets("Waivers").Range("g" & row_number)
'   TextBox8.Text = Sheets("Waivers").Range("h" & row_number)
'   TextBox9.Text = Sheets("Waivers").Range("i" & row_number)
'   TextBox10.Text = Sheets("Waivers").Range("k" & row_number)

' I need to reverse this information so that after I populate my userform with the data from waivers sheet, if someone has information to change I can make the changes in the
' form and just return them to the waviers sheet.
' I am not sure how to capture the Row_number. from the prior Sub


End Sub

' Button 4

Sub Exit1_Click()

Unload Me

MsgBox "Thank You for updating the Waivers List, Make sure you have the Hunters Sign their 2015 Waivers", vbInformation, "Don Ross"

End Sub

' Button 5

Private Sub CBBlankRelease1_Click()

ws3.Select

    ' ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
   '   IgnorePrintAreas:=False

End Sub

Private Sub UserForm_Click()

End Sub

Robbe Morris replied to Donald Ross on 15-Aug-15 08:43 PM
I'd try trimming all the compare values and the textbox values and see if that isn't the issue.
Donald Ross replied to Robbe Morris on 15-Aug-15 09:14 PM
Thank you Robbie,

It has been a while I hope you are doing well. 

My question was lost in all the VBA and I am sorry for that.  My problem is the SUB for Button 3 in that mess is what I need help with.  I am struggling with VBA so baby steps.

when I type a last name in textbox1 and search I populate my userform with all the data from sheet3 ' Waivers'

if any information has changed from last year and I type in those fields I want to be able to hit update 'CB3 and have the data fill in the sheet.  

I copied most of the VBA from different Videos and forums and picked and choose the things I needed.

I do not know how to 'trap or catch the actual Row_Number during the search SUB so that I can use it for the Update SUB.    Thanks for your help. 
Donald Ross replied to Robbe Morris on 15-Aug-15 09:33 PM
https://www.nullskull.com/FileUpload/-150785887/Hunter%20Sign%20In.zip


I hope I uploaded this right.  looks different from before.

Don
Donald Ross replied to Donald Ross on 23-Aug-15 10:17 PM
I want to thank you Robbie for your input, sorry it has taken me so long to get back to you.

I have added several more Sub's and a few more buttons to the user form I finally figured out how to do what I was asking it is not the cleanest way to do it in VBA but it works.  as I do more projects I will learn more.

Don