473,396 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Working with recordsets

Hello--I have 2 tables:

Coloncutlog: CutId (autonumber), histnum, block--indexed on those 2 fields, other info fields
Colonslides: SlideID (autonumber) CutID (from Cutlog), slide number, other data fields.

a one to many relationship between the tables--for each cut there can be numerous slides.
I originally had the slide table set up as a subform of the cutlog table so when creating a new
slide record the CutID went in automatically-but this was not preferred by the user becasue they do
not want to filter for each Cutlog record--they want to be able to enter a batch of different
records quickly and have the checking occur as they enter.

Slide data is entered in batches--the histnum and block are entered on an unbound form (along with
other fields that are common for all records entered.) The slide may exist and it may not so when
creating new slide records I want to check to see if they exist already. I have tried 2 methods:

Number one: This involves adding the histnum and block fields to the slide table
Dim db As Database
Dim rs As Recordset
Dim sql As String
Set db = CurrentDb

sql = "SELECT * from ColonSlides WHERE HistNum = '" & Me.tmpHistNum & "' And Block = '" &
Me.tmpBlock & "' And Slide = '" & Me.tmpSlide & "'"
Set rs = db.OpenRecordset(sql, dbOpenDynaset)

If rs.RecordCount > 0 Then 'record in slide table exists
rs.Edit 'Edits existing record
rs!staindate = Me.tmpstaindate
snipped other statements

rs.Update
Else
rs.AddNew 'Creates new record
rs!HistNum = Me.HistNum
rs!Block = Me.Block
rs!Slide = Me.Slide

rs.Update
End If
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing

ON THE FORM I also have code to check the cutlog table for the existence of the histlog/block index.
The problem with this approach is that data is entered in both places and it would also appear that
slides with Hist/block #s that don't exist in the cut log could be entered--even though I have code
that checks for that. Additionally, the relationship between the 2 tables, when not based on the
CutID, is indeterminate. I have tried to pull the CutID in to the slide table when creating a new
record but it is not working. If I could insert that data into the new slide record this approach
may be ok.
Number 2: sql staement is a query betwene the 2 tables--the problem with this is that new records
are created in the Cutlog for each slide entry if the entry does not already exist

Dim db As Database
Dim rs As Recordset
Dim sql As String

Set db = CurrentDb
sql = "SELECT * from qryjoincutslide WHERE HistNum = '" & Me.tmpHistNum & "' And Block = '" &
Me.tmpBlock & "' And Slide = '" & Me.tmpSlide & "'"
Set rs = db.OpenRecordset(sql, dbOpenDynaset)
If rs.RecordCount > 0 Then 'record in slide table exists

rs.Edit 'Edits existing record

rs!StainDate = Me.adate
snipped other statements
rs.Update
Else
rs.AddNew 'Creates new record
rs!HistNum = Me.tmpHistNum
rs!Block = Me.tmpBlock
rs!Slide = Me.tmpSlide
rs.Update
End If
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing

Any help would be appreciated--if more clarity is needed pleaes let me know

thank you
Bob Stafford

Nov 13 '05 #1
0 3447

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: viviane lima - * - * - | last post by:
Also idea ? how to use ASP for working .DBF files ? Please help me .. thanks Vivian
6
by: Steve Jorgensen | last post by:
I keep having problems in which ADO disconnected recordset work under some circumstances, but lose all their data at other times, having no rows or fields, though the recordset object still exists....
2
by: Pieter Linden | last post by:
The answer to this one is probably "test it yourself and find out!", but I'll ask anyway. Pursuant to my previous question - sending separate recordsets to Word using the CreateTableFromRecordset...
1
by: lakshmi | last post by:
Hi all, I recently rewrote a data intensive C++ program in C#. The C++ program was traversing 3 recordsets that were all open at the same time. I replaced those 3 recordsets with 3 .NET data...
0
by: Fraser Dickson | last post by:
I am building a web based system using ASP.NET and VB.NET which has to interact with a web service which uses XML WDDX packets. I have been given the XML Packet Specification by the Web Service...
16
by: Randy Harris | last post by:
I was inspired by the recent discussion of returning multiple recordsets to ADO from a stored procedure. (Amazed is probably more accurate). I asked about how to accomplish same with Oracle and...
2
by: Geoff | last post by:
This program is only for use as a demonstration when working with recordsets. The idea is that the record set s processed to determine how many books out by junior, adult and senior members of a...
4
by: mrmagoo | last post by:
I'm building a vb.net Forms project that is getting data from a SQL Server database. One of the main goals of the project is to be really responsive to events, such as textbox change events. I...
5
by: julian77 | last post by:
Hi, I have recetly migrated from SQL 2000 to SQL 2005 and certain .asp-code that was working before, is no longer working. Retrieving, inserting, deleting recordsets are no problem, but when I...
4
by: rdemyan via AccessMonster.com | last post by:
Can someone help me with creating code that will look for DAO recordsets in modules and then check to see if the recordset is also closed in the module. All of my recordsets are of the form rs*...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.