Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 131
  • Last Modified:

Query Than Update Problem

I am new to VB and having Problems creating the following situation;
Situation - Users input information for Product - must select from list
1)After entering information , I need to query a Different table,called "Parts", to check for Exact Matches in all fields that the user selected [ 8 fields ]
2) If match is found, I need to assign the pre-existing part # to the Product information that the customer selected, then save the new info to the "Parts" Table.
3) If match is not found,I need to assign new part number to the data and save to "Parts" Table.
 I am having problems writing the SQL statement for this operation and also how to setup the recordset operation.Any help would be greatly appreciated! Thanks!
0
apei
Asked:
apei
1 Solution
 
meetzeCommented:
what data access are you using...ADO,RDO, or DAO???
0
 
cjwikCommented:
Show some code....
0
 
arcusdCommented:
here's some of the code

dim xstr as string
dim mset as Recordset

'assume that we mdb is the database

xstr = "SELECT * FROM Parts WHERE Field1 = " + EditBox1.Text + " _
 "AND Field2 = " + EditBox2.Text + """ _
" AND ...."""  + _
" AND Field8 = " + EditBox8.Text + """

set mset = mdb.Openrecordset(xstr,dbOpenDynaset)
if not mset.eof  'found then
   mset.Edit
   mset.Fields(0) = EditBox1.Text
else
   mset.Fields(0) = GetNewPartNo() 'assuming that the first field is the part no and                                                      GetNewPartNo() is a function that returns new part number
   mset.Addnew
end if

mset.Fields(1) = EditBox2.Text
..
mset.Fields(7) = EditBox8.Text

mset.Update

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now