ECEstudent
Registered User.
- Local time
- Today, 01:42
- Joined
- Jun 12, 2013
- Messages
- 153
Hi, I'm having trouble viewing values that exist in table 'tblTest2' to the user. The first set of code (below) doesn NOT work. Yet the second set of code (all the way at the bottom) DOES work. And by work I mean that it erases the old values and only puts the tblTest2's new values. The first set of code has values but they are not the right ones. The second set of code has the correct values for its statement...
Code:
strTable = "tblTest2" 'Table for storing values for viewing purposes
DoCmd.DeleteObject acTable, strTable 'Delete tblTest2 old values
CurrentDb.Execute "CREATE TABLE tblTest2 " _
& "(RepId CHAR, OrderNumber CHAR, Item CHAR, ProductNbr CHAR, Name CHAR, [Rep Region Code] CHAR);" 'Rebuild tblTest2 for use
strSQL = ("INSERT INTO " & strTable & " Select c.OrderNumber, c.Item, c.RepId, p.ProductNbr, p.Name, [tbl_LBP_Sales Location Num].[Rep Region Code] FROM CalculateTotal c, dbo_PartNew p, [tbl_LBP_Sales Location Num] WHERE ([Structure] like '*" & u & "*') AND ([ProductNbr] = '" & txtPartNumber & "')")
CurrentDb.Execute strSQL
DoCmd.OpenTable "tblTest2", acViewPreview
Code:
strTable = "tblTest2" 'Table values are uploaded to for viewing at end
DoCmd.DeleteObject acTable, strTable 'Delete table values from past run
CurrentDb.Execute "CREATE TABLE tblTest2 " _
& "(PartNumber CHAR, OrderTotal CHAR, ItemQty CHAR);" 'Rebuild table
strSQL = "INSERT INTO tblTest2 ([PartNumber],[OrderTotal], [ItemQty]) Values ('" & NewValue & "', '" & VldOrdrNbrDestination & "', '" & ItemQuantity & "')" 'Insert values in table tblTest2 for the user to view
DoCmd.OpenTable "tblTest2", acViewPreview