C
craignbaker
In my syntax I can create input boxes for a number of fields but in one of
the fields which contains details of the number of stock on hand for that
item I am trying to work out the syntax to add stock for that item. I'll
provide you with the syntax I have tried so far.
Private Sub CmdAddStock_Click()
'this subroutines allows records to be added to a recordset
'declares a database object variable
Dim mydb As Database
'declares a recordset object variable
Dim myset As Recordset
'sets up a variable to continue adding records or not
Dim AnotherRecord As String
'sets the object variable mydb to the current database.
'currentdb() is a function that returns the current database.
Set mydb = CurrentDb()
'creates a copy of the recordset from the Item table in memory
Set myset = mydb.OpenRecordset("Item")
'loops until the user says they do not wish to add more records
Do
'adds a new record in the recordset
myset.AddNew
'gets the value of ItemDesc, Price and OnHand
myset!ItemDesc = InputBox("Enter the ItemDesc")
myset!Price = InputBox("Enter the Price")
myset!OnHand = InputBox("Enter the OnHand" + "Enter the amount to be
added")
'updates the recordset in the database
myset.Update
AnotherRecord = InputBox("Enter a New Record Y/N")
Loop Until AnotherRecord = "N"
'closes the recordset
myset.Close
End Sub
Any information will be appreciated.
the fields which contains details of the number of stock on hand for that
item I am trying to work out the syntax to add stock for that item. I'll
provide you with the syntax I have tried so far.
Private Sub CmdAddStock_Click()
'this subroutines allows records to be added to a recordset
'declares a database object variable
Dim mydb As Database
'declares a recordset object variable
Dim myset As Recordset
'sets up a variable to continue adding records or not
Dim AnotherRecord As String
'sets the object variable mydb to the current database.
'currentdb() is a function that returns the current database.
Set mydb = CurrentDb()
'creates a copy of the recordset from the Item table in memory
Set myset = mydb.OpenRecordset("Item")
'loops until the user says they do not wish to add more records
Do
'adds a new record in the recordset
myset.AddNew
'gets the value of ItemDesc, Price and OnHand
myset!ItemDesc = InputBox("Enter the ItemDesc")
myset!Price = InputBox("Enter the Price")
myset!OnHand = InputBox("Enter the OnHand" + "Enter the amount to be
added")
'updates the recordset in the database
myset.Update
AnotherRecord = InputBox("Enter a New Record Y/N")
Loop Until AnotherRecord = "N"
'closes the recordset
myset.Close
End Sub
Any information will be appreciated.