473,322 Members | 1,911 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,322 software developers and data experts.

open recordset

I am creating a new recordset in 2 tables, orders and order
details.Obviously i have to open the recordset
for two tables.Shall i open the recordset for the table order details
and when shall i open it ?
My function shown below does not create a new recordset in the second
table,only in the table orders:

Public Function CreateOrder()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim lngOrderID As Long
Dim strSQL As String
On Error GoTo ErrHandler

' Create a new order and obtain its OrderID
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Orders", dbOpenDynaset)
rst.AddNew
rst!customerid = DMin("Customerid", "Customers")
rst!SubOrder = True
rst!Audit = True
rst!bankid = 1
lngOrderID = rst!orderid
rst.Update
' Add order details
strSQL = "INSERT INTO [Order Details] (OrderID, ProductID, Cartons,
Quantity) " & _
"SELECT " & lngOrderID & ", ProductID, Branch0, Items0 FROM
Products " & _
"WHERE Branch0 > 0 AND Items0 > 0"
dbs.Execute strSQL, dbFailOnError
ExitHandler:
On Error Resume Next
rst.Close
Set rst = Nothing
Set dbs = Nothing
Exit Function
ErrHandler:
MsgBox Err.Description, vbExclamation
Resume ExitHandler
End Function

Feb 10 '06 #1
0 1626

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

Similar topics

4
by: Dalan | last post by:
I presume that using an open recordset method is the preferred method of accomplishing what I'm trying to do. Of course, if there are other options that would work, feel free to share them. I...
13
by: Seth Spearman | last post by:
Hey guys, I have the following code: '****************************************************** If Not Me.NewRecord Then Dim rs As DAO.Recordset Dim strBookmark As String Set rs =...
2
by: Colleyville Alan | last post by:
I ran into problems in an app in which I received a msg of "cannot lock the table, it is in use by another user". It turns out that I had opened a recordset with a command like set rstmyrecs =...
2
by: Sunil Korah | last post by:
I am having some trouble with opening recordsets. I have used code more or less straight from the access help. But still I am getting some errors. I am unable to work out what exactly I am doing...
0
by: solar | last post by:
I am creating a new recordset in 2 tables, orders and order details.Obviously i have to open the recordset for two tables.Shall i open the recordset for the table order details and when shall i...
6
by: blue875 | last post by:
Hello helper people who are smarter than me: I have a form that needs to submit multiple queries to different tables during one Sub's execution. Some sections are as simple as: 1| With rst 2|...
2
by: Jim M | last post by:
I rarely deal with recordsets directly with code, since I usually use Access queries, so be patient with this question. I want to open a recordset with various default variables used by my program....
23
by: PW | last post by:
Hi, I'd like to close a recordset and set the database to nothing if a recordset is open if an error has occured. Leaving a recordset open and a database open isn't a good idea, right? ...
8
by: metalheadstorm | last post by:
ok ive set up a connection between my access db ( 97) and my vb6 interface and this is what i got form_load Data6.DatabaseName = App.Path & "\cjmillers.mdb" Data6.RecordSource = "select * from...
2
by: Kosmos | last post by:
I am opening the following connections as such although I am only referring to the first connection for this question: Dim con1 As ADODB.Connection Dim con2 As ADODB.Connection Dim recSet1 As...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.