Private Sub Form_Load()
Dim obook As Workbook
Dim osheet As Worksheet
Dim var As Variant
Dim var2 As Variant
Dim var5 As Variant
If Dir("C:\Documents and Settings\All Users\Desktop\Test.xls") <> "" Then 'check for this file
ElseIf Dir("C:\Documents and Settings\All Users\Desktop\Test.xls") = "" Then
Open "C:\Documents and Settings\All Users\Desktop\Test.xls" For Append As #1
Print #1, "Part Number" & vbTab & "Description" & vbTab & "Quantity" 'put these columns in fil
Text3.Text = "1"
Set obook = OLE1.object
Set osheet = obook.Sheets(1)
Do Until Text3.Text = "800"
var = osheet.Range("B" + Text3.Text).Value
var2 = osheet.Range("A" + Text3.Text).Value
var5 = osheet.Range("C" + Text3.Text).Value
Text2.Text = var
Text5.Text = var5
Text3.Text = Text3.Text + 1
Print #1, var2 & vbTab & var & vbTab & var5
Loop
MsgBox "File was created On desktop"
obook.Close
End If
Combo1.Text = ""
Text3.Text = 1
Text2.Text = " "
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer) 'press enter in part number starts search
If KeyAscii = 13 Then ' The ENTER key.
Command1 = 1
End If
End Sub
[color="#FF0000"]Private Sub Text5_KeyPress(KeyAscii As Integer) 'press enter in Quantity writes amount to part number
If KeyAscii = 13 Then ' The ENTER key.
Dim xlApp As Object
Dim wb As Object
Dim ws As Object
Dim var9 As Variant
Dim var10 As Variant
Set xlApp = New Excel.Application
Set wb = xlApp.Workbooks.Open("C:\Documents and Settings\All Users\Desktop\Test.xls")
Set ws = wb.Worksheets("Test").Range(Text1.Text)
var9 = ws.Range("C9") = "Text5.Text"
wb.Close
xlApp.Quit
Set ws = Nothing
Set wb = Nothing
Set xlApp = Nothing
MsgBox "this is working"
Combo1.SetFocus
End If
[/color]
End Sub
Private Sub Command1_Click() 'searches for item
Dim xlApp As Excel.Application
Dim wb As Workbook
Dim ws As Worksheet
Dim var As Variant
Text2.Text = " "
Text3.Text = 1
Text4.Text = ""
Label2.Visible = True
Command1.Enabled = False
Text5.SetFocus
If Option1 = True Then 'searches by description
Set xlApp = New Excel.Application
Set wb = xlApp.Workbooks.Open("C:\Documents and Settings\All Users\Desktop\Test.xls")
Set ws = wb.Worksheets("Test") 'Specify your worksheet name
Do Until Combo2.Text = Text2.Text Or Text2.Text = "" Or Text3.Text = "800"
var = ws.Range("B" + Text3.Text).Value
var2 = ws.Range("A" + Text3.Text).Value
var5 = ws.Range("C" + Text3.Text).Value
Text2.Text = var
Text5.Text = var5
Text4.Text = var2
Text3.Text = Text3.Text + 1
Loop
wb.Close
xlApp.Quit
Set ws = Nothing
Set wb = Nothing
Set xlApp = Nothing
'------------------------------------------------------------------------------------------------
If Combo2.Text = Text2.Text Then
Text4.Text = var2
Label2.Visible = False
Command1.Enabled = True
Text3.Text = 1
Text2.Text = " "
Set ws = Nothing
Set wb = Nothing
Set xlApp = Nothing
End If
ElseIf Option2.Value = True Then
Set xlApp = New Excel.Application
Set wb = xlApp.Workbooks.Open("C:\Documents and Settings\All Users\Desktop\Test.xls")
Set ws = wb.Worksheets("Test") 'Specify your worksheet name
Do Until Combo1.Text = Text2.Text Or Text2.Text = "" Or Text3.Text = "800"
var = ws.Range("A" + Text3.Text).Value
var2 = ws.Range("B" + Text3.Text).Value
var5 = ws.Range("C" + Text3.Text).Value
Text2.Text = var
Text4.Text = var2
Text5.Text = var5
Text3.Text = Text3.Text + 1
Text1.Text = ("C" & (Text3.Text - 1))
Loop
wb.Close
xlApp.Quit
Set ws = Nothing
Set wb = Nothing
Set xlApp = Nothing
If Combo1.Text = Text2.Text Then
Text4.Text = var2
Label2.Visible = False
Command1.Enabled = True
Text2.Text = " "
End If
Set ws = Nothing
Set wb = Nothing
Set xlApp = Nothing
End If
End Sub
Private Sub Option1_Click()
Combo1.Enabled = False
Combo2.Enabled = True
End Sub
Private Sub Option2_Click()
If Option2 = True Then
Combo1.Enabled = True
Combo2.Enabled = False
End If
End Sub
Sub SelectAllText(Textbox5 As TextBox)
Textbox5.SelStart = 0
Textbox5.SelLength = Len(Textbox5.Text)
End Sub
Private Sub Text5_GotFocus()
SelectAllText Text5
End Sub
For whatever reason the color doesnt seem to work, so the problem I am having starts at line 057 and ends at 087

New Topic/Question
Reply



MultiQuote




|