[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Query Than Update Problem

Posted on 1999-01-29
3
Medium Priority
?
129 Views
Last Modified: 2010-05-03
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
Comment
Question by:apei
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:meetze
ID: 1471218
what data access are you using...ADO,RDO, or DAO???
0
 
LVL 2

Expert Comment

by:cjwik
ID: 1471219
Show some code....
0
 
LVL 4

Accepted Solution

by:
arcusd earned 200 total points
ID: 1471220
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question