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

RecordsetClone - referencing another form

Hi,

I have just been on an access course and was given the following code:
Expand|Select|Wrap|Line Numbers
  1. Dim rs As DAO.Recordset
  2. Set rs = Forms!frmFilm.Form.RecordsetClone
  3.  
  4. Call rs.FindFirst("FilmID =" & Me.lstFilm.Value)
  5. Forms!frmFilm.Recordset.Bookmark = rs.Bookmark
  6. Call DoCmd.Close(acForm, "frmFindFilm")
  7.  
  8. I have a form called frmFilm and a form called frmFindFilm, the above code is in the frmFindFIlm module. I'm using access 2002 (and have also tried it on access 2003) and the following error occurs:
  9.  
  10. Run-time error '2450':
  11.  
  12. Film Library can't find the form 'frmFilm' referenced in a macro expression or visual basic code. When I click debug the following line is highlighted:
  13.  
  14. Set rs = Forms!frmFilm.RecordsetClone
Can anyone help? Thanks

Gemma
Apr 7 '08 #1
3 5694
PianoMan64
374 Expert 256MB
Hi,

I have just been on an access course and was given the following code:

Dim rs As DAO.Recordset
Set rs = Forms!frmFilm.Form.RecordsetClone

Call rs.FindFirst("FilmID =" & Me.lstFilm.Value)
Forms!frmFilm.Recordset.Bookmark = rs.Bookmark
Call DoCmd.Close(acForm, "frmFindFilm")

I have a form called frmFilm and a form called frmFindFilm, the above code is in the frmFindFIlm module. I'm using access 2002 (and have also tried it on access 2003) and the following error occurs:

Run-time error '2450':

Film Library can't find the form 'frmFilm' referenced in a macro expression or visual basic code. When I click debug the following line is highlighted:

Set rs = Forms!frmFilm.RecordsetClone

Can anyone help? Thanks

Gemma
Gemmal,

Ok, the reason that the reference line that you're speaking about doesn't work, you're assuming the form that it's trying to reference is Open. The reason it fails is because there isn't an active reference to the recordset. You'll need to create the recordset within the code block that you're speaking of in order to make use of it.

for example:

Expand|Select|Wrap|Line Numbers
  1. Dim db as DAO.Database
  2. dim rs as DAO.Recordset
  3.  
  4. 'Set rs = db.OpenRecordset("The Name of the table that you're wanting the information from",dbOpenDynaset)
  5.  
  6. 'Example
  7.  
  8. Set rs = db.OpenRecordSet("SELECT * FROM [Film Table] WHERE FilmID=" & me.lstFilm.value, dbOpenDynaset)
  9.  
  10. 'Then you can simply display that recordset in a listbox or set the Recordset to the active form, as long as the active form is of the same structure as the table it is coming from?
  11.  
  12. 'otherwise, I would simply display that in a listbox control
  13.  
  14.  
If you need help as to how to bind that to another control on a form, or how to display the results in a listbox control, let me know, I can send you code examples.

Hope that helps,

Joe P.
Apr 7 '08 #2
Ji Joe,

Do you mind sending the code examples as i need this to my application. I have got a recordset with 22 columns and rows may varry, I need this data to be displayed on grid view control or similar.
I have used this but its failed
Gridview4.DataSource = MyRSet.
Comes up with Run time error 438.
Also i need a functionality to edit one of the colum and update in database accordingly.
Much appreciated if you can send me the code
Apr 8 '08 #3
PianoMan64
374 Expert 256MB
Ji Joe,

Do you mind sending the code examples as i need this to my application. I have got a recordset with 22 columns and rows may varry, I need this data to be displayed on grid view control or similar.
I have used this but its failed
Gridview4.DataSource = MyRSet.
Comes up with Run time error 438.
Also i need a functionality to edit one of the colum and update in database accordingly.
Much appreciated if you can send me the code
Ok, take what I've already sent you to connect to the data and if you're wanting to bind that to your List control Gridview4 then here's what you need to do.

In the same routine and the following line of code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. me.gridview4.rowsource = MyRSet.Name
  3.  
  4.  
Please make sure that the number of columns and the columnwidths are set to display the data the way that you want it to.

If you have more questions, let me know.

Joe P.
Apr 8 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

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 =...
3
by: Anthony Kroes | last post by:
I have a subform on a form and they are not linked. On the main form is a text box where the user types in a number. When that number changes, I have some code to make the corresponding text...
3
by: Ian Bailey | last post by:
I have developed a routine that opens a number of forms with each form being positioned on a particular record. I am using the Recordsetclone to find the record and then setting the form bookmark...
3
by: GGerard | last post by:
Hello I am trying to refer in code to the RecordsetClone of a subform datasheet but I'm getting syntax errors. This is what I am writing: Set MyDB = DBEngine.Workspaces(0).Databases(0)...
22
by: Br | last post by:
First issue: When using ADPs you no longer have the ability to issue a me.refresh to save the current record on a form (the me.refresh does a requery in an ADP). We usually do this before...
3
by: G Gerard | last post by:
Hello Can I write an SQL statement in code using a RecordSetClone of an open form? something like: MySQL = "UPDATE Me!Child0.Form.RecordSetClone SET Me!Child0.Form.RecordSetClone.MyField =...
1
by: Orchid | last post by:
Hello all, I have a Combo Box on a form with selection of a firm list. When the users select a firm from the Combo Box and if the firm has branch(es), a list of branch(es) of the firm opens in a...
10
by: d.francis | last post by:
I have converted an Access 97 database to Access 2003 The following code now fails and returns Run-time error '3420' Dim rst as DAO.recordset Set rst = Forms!frm1!frm2.Form.RecordsetClone I...
2
by: Certys | last post by:
Hello, I have a form where I only allow new records to be added. I enable this by setting the form property "Data Entry" to Yes. I want to access other records in the same table- to autofill...
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...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.