Re: Problem with Code Because I already have an Open Query

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks John,
But I still get an error on the line:

Set MySet = CurrentDb.OpenRecordset("ACCOUNTS")

because the query ACCOUNTS is open due to filter from a form.

Ange



"J_Goddard via AccessMonster.com" <u37558@uwe> wrote in message
news:7f630c5cacbf6@xxxxxx
Hi -

By 'stuck', do you mean runtime or compile error?


You need

Dim MySet as DAO.recordset, myset2 as DAO.recordset

and then
'
' Queries are opened into recordsets just as tables are
'
Set Myset = CurrentDb.openrecordset("ACCOUNTS")
Set Myset2 = db1.OpenRecordset("ACCOUNTS CHARGED")

I assume that db1 is another database that you have established a link to?

The code looks fine otherwise.

John



Ange Kappas wrote:
Hi,
I have already open a Query named ACCOUNTS and I want to copy the
already filtered results into a Table name ACCOUNTS CHARGED.
The code is stuck on the Set Myset=CurrentDb("ACCOUNTS")

What do I have to adjust to make it work?

Thanks

Private Sub ACCOUNTS_CHARGE_Click()

Dim PoseidonHotelProgram As Database
Dim rsta As DAO.Recordset
Dim frm As Form
Dim Msg, Style, Title, Response, MyString

Set Myset = CurrentDb("ACCOUNTS")
Set Myset2 = db1.OpenRecordset("ACCOUNTS CHARGED")

With Myset
If Not .EOF Then
.MoveFirst
End If
Do While Not .EOF
Myset2.AddNew
Myset2![Date] = Myset![Date]
Myset2![RESNO] = Myset![RESNO]
Myset2![RESNAME] = Myset![RESNAME]
Myset2![COMPANY] = Myset![COMPANY]
Myset2![ROOMNO] = Myset![ROOMNO]
Myset2![ROOMTYPE] = Myset![ROOMTYPE]
Myset2![BASIS] = Myset![BASIS]
Myset2![ARRIVAL] = Myset![ARRIVAL]
Myset2![DAYS] = Myset![DAYS]
Myset2![DEPARTURE] = Myset![DEPARTURE]
Myset2![DAILY CHARGE] = Myset![DAILYRATE]
Myset2.Update
.MoveNext
Loop
End With
Myset2.Close

End Sub

--
John Goddard
Ottawa, ON Canada
jrgoddard at cyberus dot ca

Message posted via http://www.accessmonster.com



.



Relevant Pages

  • Re: Problem with Code Because I already have an Open Query
    ... why go to the trouble of opening a recordset when you could just use an ... That way when you need to know which accounts ... you just run a query that picks up the charged accounts. ... Set MySet = CurrentDb.OpenRecordset ...
    (microsoft.public.access.forms)
  • Re: Problem with Code Because I already have an Open Query
    ... You see I have a QUERY which has records where every day a Guest is charged ... In the QUERY "ACCOUNTS" under the fields COMPANY. ... Now from there I use a Form "ACCOUNTS SEARCH" with a SubForm to filter out ... Set MySet = CurrentDb.OpenRecordset ...
    (microsoft.public.access.forms)
  • Re: Best Practice to close Database
    ... Dim SQLStg As String ... Dim MyDb As Database ... Set MySet = MyDb.OpenRecordset ... Set db = CurrentDB ...
    (comp.databases.ms-access)
  • Re: Reducing the List items on a combo
    ... Dim Mydb As Database ... Dim MySet As Recordset ... Set MySet = Mydb.OpenRecordset ... Do Until!MaterialID = CLng ...
    (comp.databases.ms-access)
  • Re: Problem stepping thru a record set
    ... Set MySet = MyDB.OpenRecordset("Select * from Tracked Order By ... Dim MyTable As DAO.Recordset ... Dim MyDB As DAO.Database ... Set DB = CurrentDb() ...
    (microsoft.public.access.modulesdaovba)