I think this should be easy - set a value in a table

D

dhstein

I'm trying to update the field in a table from by reading in a text file.
The code is below

Dim rs As DAO.Recordset
Dim rsProducts As DAO.Recordset


Set rsProducts = CurrentDb.OpenRecordset("tblProduct")
rsProducts.Index = "ProductSKU"

..
.. Other Code here
..


Set rs = CurrentDb.OpenRecordset("Set_Product_Table", dbOpenSnapshot)



rsProducts.Seek "=", ![ProductSKU]
If rsProducts.NoMatch Then
MsgBox "This is a new item"
MsgBox ![ProductSKU]
With rsProducts
.AddNew
'?????????????????????????????????
' What code here sets the ProductSKU field for the new
record
'in the products table to the value
' of ProductSKU that is displayed in the MsgBox above?
' ???????????????????????????????
.Update
End With


Thanks for any help on this.
 
A

Arvin Meyer [MVP]

' What code here sets the ProductSKU field for the new record

!ProductSKU = Me.txtProductSKU

or:

!ProductSKU = "12345678"
 
D

dhstein

Arvin Meyer said:
' What code here sets the ProductSKU field for the new record

!ProductSKU = Me.txtProductSKU

or:

!ProductSKU = "12345678"
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


dhstein said:
I'm trying to update the field in a table from by reading in a text file.
The code is below

Dim rs As DAO.Recordset
Dim rsProducts As DAO.Recordset


Set rsProducts = CurrentDb.OpenRecordset("tblProduct")
rsProducts.Index = "ProductSKU"

.
. Other Code here
.


Set rs = CurrentDb.OpenRecordset("Set_Product_Table", dbOpenSnapshot)



rsProducts.Seek "=", ![ProductSKU]
If rsProducts.NoMatch Then
MsgBox "This is a new item"
MsgBox ![ProductSKU]
With rsProducts
.AddNew
'?????????????????????????????????
' What code here sets the ProductSKU field for the new
record
'in the products table to the value
' of ProductSKU that is displayed in the MsgBox above?
' ???????????????????????????????
.Update
End With


Thanks for any help on this.


Thanks for trying Arvin - but that didn't work - got the message method or data member not found
 
A

Arvin Meyer [MVP]

You must make sure that all the names of the objects are correct. I used
generic names based upon your post.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


dhstein said:
Arvin Meyer said:
' What code here sets the ProductSKU field for the new record

!ProductSKU = Me.txtProductSKU

or:

!ProductSKU = "12345678"
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


dhstein said:
I'm trying to update the field in a table from by reading in a text
file.
The code is below

Dim rs As DAO.Recordset
Dim rsProducts As DAO.Recordset


Set rsProducts = CurrentDb.OpenRecordset("tblProduct")
rsProducts.Index = "ProductSKU"

.
. Other Code here
.


Set rs = CurrentDb.OpenRecordset("Set_Product_Table", dbOpenSnapshot)



rsProducts.Seek "=", ![ProductSKU]
If rsProducts.NoMatch Then
MsgBox "This is a new item"
MsgBox ![ProductSKU]
With rsProducts
.AddNew
'?????????????????????????????????
' What code here sets the ProductSKU field for the
new
record
'in the products table to the value
' of ProductSKU that is displayed in the MsgBox above?
' ???????????????????????????????
.Update
End With


Thanks for any help on this.


Thanks for trying Arvin - but that didn't work - got the message method
or data member not found
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top