473,503 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

creating an inventory application

Let me start by saying that I'm a newbie in VBA.

I've created an application in access where the user enters the quantity of
the items sold in a form. I would like to have these records created in a
table, mentioning the qty sold, the transaction date etc. this table I'm
planning to use afterward to calculate the quantity on hand.

I have created the following code, but I keep on receiving the error, that
it does not recognize the fields mentioned in the code.

Private Sub Form_AfterUpdate()
Dim rst As DAO.Recordset
Dim mdbLocal As DAO.Database
Set mdbLocal = DBEngine(0)(0)
Set rst = mdbLocal.OpenRecordset("visits", dbOpenDynaset, dbAppendOnly)

If Me![Owndepomys] = False Then
[Inventory.Storeroom] = "FP02"
[Inventory.TransactionDate] = Me![Datevisit]
[Inventory.Artcode] = DLookup("[ArtCode]", "Contraceptives", "
[Description]=" & Forms![visits]!Description)
[Inventory.Description] = Me![Contraceptives]
[Inventory.TransactionDescription] = "Over the counter"
[Inventory.UnitsSold] = Me![Qty]
[Inventory.Qtyonhand] = [Inventory.Qtyonhand] - Me![Qty]
[Inventory.AmountQty] = [Inventory.AmountQty] * Me!
[Contraceptives.Price]
rst.AddNew

End If

End Sub

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #1
2 2147
you need to prefix the field names with the name of the recordset...

If Not Me![MyBoolean] Then
'--ADD A NEW RECORD
rst.AddNew
'--Set the values for individual fields
rst.Fields("Inventory Storeroom")="FP02"
rst.fields("ArtCode")="Whatever"
'--Save the record
rst.UPDATE
End If

Nov 13 '05 #2
Thanks for your reaction, I've changed my code as per your suggestion and I
still get the same error code 2465, "can't find field "|" referred to in
your expression."

This is the changed code. Could you have a look at it again? Thanks again
for your help.

Private Sub Form_AfterUpdate()
'If Me.NewRecord Then

Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Transaction Table", dbOpenTable)

If Not Me![Owndepomys] Then
rst.AddNew
rst.Fields([Transaction Table].[Storeroom]) = "FP02"
[Transaction Table.TransactionDate] = Me![Datevisit]
[Transaction Table.Artcode] = DLookup ("[ArtCode]",
"Contraceptives", "[Description]=" & Forms![visits]!Description)
[Transaction Table.TransactionDescription] = "Over the counter"
[Transaction Table.UnitsSold] = Me![Qty]
[Transaction Table.AmountQty] = [Transaction Table.AmountQty] * Me!
[Contraceptives.Price]
rst.Update

End If
'End If

'err_Form_AFterUpdate:
Exit Sub
End Sub

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2729
by: Edvard Majakari | last post by:
Greetings, fellow Pythonistas! I'm about to create three modules. As an avid TDD fan I'd like to create typical 'use-cases' for each of these modules. One of them is rather large, and I wondered...
10
3456
by: Susan M. | last post by:
I'm trying to do a query that joins two tables. The trick is that I only want it to return rows based on a certain criteria. Table 1: Inventory Fields: Inventory #, Description Table 2:...
0
2183
by: Tom | last post by:
Using AccessXP - Access2000 In my application, when an order is entered, inventory is automatically adjusted, a pull list is created, items are pulled to fill the order, and the order is...
3
8962
by: Sefa Sevtekin | last post by:
I am trying to create a c# typesafe collection to avoid typecasting exceptions and to ease binding of grids to collections. I already did it in VB.NET but couldn't map it to C#. In VB.NET you need...
4
2954
by: DeepDiver | last post by:
I am developing an inventory database in SQL Server. I realize there are many commercial (as well as some non-commercial) inventory offerings, but my client has specific requirements that would...
0
7092
by: south622 | last post by:
I'm taking a beginning Java course and I'm stuck in week eight of a nine week course. If anyone could help me I would greatly appreciate it. This assignment was due yesterday and each day I go past...
6
3869
sammyboy78
by: sammyboy78 | last post by:
I'm trying to display my array of objects in a GUI. How do I get JLabel to refer to the data in my objects? I've read my textbook and some tutorials online I just cannot get this. Plus all the...
9
7595
by: xxplod | last post by:
I am suppose to modify the Inventory Program so the application can handle multiple items. Use an array to store the items. The output should display the information one product at a time, including...
3
6966
by: cblank | last post by:
I need some help if someone could help me. I know everyone is asking for help in java. But for some reason I'm the same as everyone else when it comes to programming in java. I have an inventory...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7087
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.