JeremyA1976
Board Regular
- Joined
- Aug 3, 2015
- Messages
- 59
I am trying to link two workbooks together. I have a main form and I have a log. I have already created the log with sequential numbering starting at 120000. This will be my charge out number. On my main form template, the user's first responsibility is to fill out the userform information (Date, job number, customer, author & charge out number). Once the text fields are filled out and submitted, they populate my main form basic information on sheet1.
Date = Cell M1
CO# = Cell O1
Job No. = Cell M2
Customer = Cell M3
Author = Cell M4
The user then fills out all the charge out materials which results in a list of pertinent information on my main form. What i would like to see happen is for the userform "ChargeOutInfo" to automatically look in the workbook "Charge Out Log.xlsm", find the last entry in column B, go one row down and retrieve the Charge out number in column A. I currently have a textbox in the userform to manually input a number, but it should be replaced with the retrieved number from the log, so that the user can NOT change this number. Here is the code I have for my ChargeOutInfo for the submit button:
Private Sub ChargeOutInfo_Initialize()
End Sub
Private Sub Image2_Click()
Dim ws1 As Worksheet
Set ws1 = Worksheets("CHARGE OUT FORM")
'Charge Out Form
ws1.Range("M1") = Date
ws1.Range("O1") = TextBox1.Value
ws1.Range("M2") = TextBox2.Value
ws1.Range("M3") = TextBox3.Value
ws1.Range("M4") = TextBox4.Value
ws1.Range("N5") = TransferfromJobNo.Value
Dim i As Long
Dim ans As String
Dim Ms As String
Dim Mss As String
Mss = "ALL Textboxes must be filled in!"
Ms = "These TextBoxs are empty"
For i = 4 To 1 Step -1
If Controls("TextBox" & i).Value = "" Then ans = Controls("Textbox" & i).Name & vbNewLine & ans
Next
If ans <> "" Then
MsgBox Ms & vbNewLine & ans & vbNewLine & Mss
Else
MsgBox "All Information is Added. Thank You!"
End If
End
End Sub
I would like for the retrieved charge out number to show up on the userform, but its not a necessity at this point. As long as each charge out submission has a different number for tracking, then i can deal with everything else. Can someone please help shed some light on this for me? Thanks
Date = Cell M1
CO# = Cell O1
Job No. = Cell M2
Customer = Cell M3
Author = Cell M4
The user then fills out all the charge out materials which results in a list of pertinent information on my main form. What i would like to see happen is for the userform "ChargeOutInfo" to automatically look in the workbook "Charge Out Log.xlsm", find the last entry in column B, go one row down and retrieve the Charge out number in column A. I currently have a textbox in the userform to manually input a number, but it should be replaced with the retrieved number from the log, so that the user can NOT change this number. Here is the code I have for my ChargeOutInfo for the submit button:
Private Sub ChargeOutInfo_Initialize()
End Sub
Private Sub Image2_Click()
Dim ws1 As Worksheet
Set ws1 = Worksheets("CHARGE OUT FORM")
'Charge Out Form
ws1.Range("M1") = Date
ws1.Range("O1") = TextBox1.Value
ws1.Range("M2") = TextBox2.Value
ws1.Range("M3") = TextBox3.Value
ws1.Range("M4") = TextBox4.Value
ws1.Range("N5") = TransferfromJobNo.Value
Dim i As Long
Dim ans As String
Dim Ms As String
Dim Mss As String
Mss = "ALL Textboxes must be filled in!"
Ms = "These TextBoxs are empty"
For i = 4 To 1 Step -1
If Controls("TextBox" & i).Value = "" Then ans = Controls("Textbox" & i).Name & vbNewLine & ans
Next
If ans <> "" Then
MsgBox Ms & vbNewLine & ans & vbNewLine & Mss
Else
MsgBox "All Information is Added. Thank You!"
End If
End
End Sub
I would like for the retrieved charge out number to show up on the userform, but its not a necessity at this point. As long as each charge out submission has a different number for tracking, then i can deal with everything else. Can someone please help shed some light on this for me? Thanks