#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 29
Default Creating A Form

I have created a simple inventory form. I am not very familiar with VBE, but
found a simple code I can use to run it.

How do I add to the code to sum the total of parts available, i.e.
=sumif(a2:A10="New entry")?

Here is the form layout:

Part No:
Location:
Date Received:
Number Recieved:
Amount On Hand: (Need formula)

Here is the code:

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a part number
If Trim(Me.txtPart.Value) = "" Then
Me.txtPart.SetFocus
MsgBox "Please enter a part number"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtPart.Value
ws.Cells(iRow, 2).Value = Me.txtLoc.Value
ws.Cells(iRow, 3).Value = Me.txtDate.Value
ws.Cells(iRow, 4).Value = Me.txtQty.Value

'clear the data
Me.txtPart.Value = ""
Me.txtLoc.Value = ""
Me.txtDate.Value = ""
Me.txtQty.Value = ""
Me.txtPart.SetFocus

End Sub

Thanks for all your help!
Johnnie


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 12
Default Creating A Form

create a label on your form, and everytime you add an item, update the
label;

example code:
result = Application.WorksheetFunction.Sum( <= add your arguments here
for what you want to sum,
YourForm.lblCalculated.Caption = "Value is : " & result


"Johnnie" wrote in message
...
I have created a simple inventory form. I am not very familiar with VBE,
but
found a simple code I can use to run it.

How do I add to the code to sum the total of parts available, i.e.
=sumif(a2:A10="New entry")?

Here is the form layout:

Part No:
Location:
Date Received:
Number Recieved:
Amount On Hand: (Need formula)

Here is the code:

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a part number
If Trim(Me.txtPart.Value) = "" Then
Me.txtPart.SetFocus
MsgBox "Please enter a part number"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtPart.Value
ws.Cells(iRow, 2).Value = Me.txtLoc.Value
ws.Cells(iRow, 3).Value = Me.txtDate.Value
ws.Cells(iRow, 4).Value = Me.txtQty.Value

'clear the data
Me.txtPart.Value = ""
Me.txtLoc.Value = ""
Me.txtDate.Value = ""
Me.txtQty.Value = ""
Me.txtPart.SetFocus

End Sub

Thanks for all your help!
Johnnie



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 29
Default Creating A Form

Tieski,
Thanks for the response. However, I realized I did not phrase the request
for assistance correctly.

I need help in creating a new line on the that, when a new order is entered,
the code will search to see if the part number already exists and the do
calculation for only those line items which contain that part number and give
a total on hand.

If you think this is to complicated for a novice like me, please let me know
and I will just work with the spreadsheet view.

Once again, thanks for all your help.

"Tieske" wrote:

create a label on your form, and everytime you add an item, update the
label;

example code:
result = Application.WorksheetFunction.Sum( <= add your arguments here
for what you want to sum,
YourForm.lblCalculated.Caption = "Value is : " & result


"Johnnie" wrote in message
...
I have created a simple inventory form. I am not very familiar with VBE,
but
found a simple code I can use to run it.

How do I add to the code to sum the total of parts available, i.e.
=sumif(a2:A10="New entry")?

Here is the form layout:

Part No:
Location:
Date Received:
Number Recieved:
Amount On Hand: (Need formula)

Here is the code:

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a part number
If Trim(Me.txtPart.Value) = "" Then
Me.txtPart.SetFocus
MsgBox "Please enter a part number"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtPart.Value
ws.Cells(iRow, 2).Value = Me.txtLoc.Value
ws.Cells(iRow, 3).Value = Me.txtDate.Value
ws.Cells(iRow, 4).Value = Me.txtQty.Value

'clear the data
Me.txtPart.Value = ""
Me.txtLoc.Value = ""
Me.txtDate.Value = ""
Me.txtQty.Value = ""
Me.txtPart.SetFocus

End Sub

Thanks for all your help!
Johnnie



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a Form Claudine Excel Worksheet Functions 2 December 5th 06 10:59 PM
Creating a form oakridge Excel Worksheet Functions 0 May 18th 06 01:22 PM
creating a form aprylddd New Users to Excel 1 September 20th 05 09:45 AM
Creating a Form Marcia3641 Excel Discussion (Misc queries) 10 July 21st 05 06:15 PM
Creating a Search Form Karen Excel Discussion (Misc queries) 12 April 1st 05 07:02 AM


All times are GMT +1. The time now is 07:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"