Solved

Query Than Update Problem

Posted on 1999-01-29
3
124 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 100 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

733 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