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
Solved

Query Than Update Problem

Posted on 1999-01-29
3
123 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
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
Access 2013 combo box not working 3 51
vb6 connector to mongodb 2 117
Error with a code discussed on this page 5 29
Problem to line 23 53
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

807 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