Datasheet help

Yippiekaiaii

Registered User.
Local time
Today, 19:54
Joined
Mar 25, 2013
Messages
21
I am trying loop through a datasheet so that I can copy the contents of one field into another form.

I have tried using the bellow code to do this on a button click event. However when i run it I get an error telling me that the object doesn't support this property or method. Im not quite sure what this means.

Can someone help me with this?


Dim rst As DAO.Recordset
Set rst = Forms![Roll Out - Site Form]![Roll Out - Sign items pick list].RecordsetClone
Do Until rst.EOF

[Roll Out - Sign items added].Form!
Code:
 = [Roll Out - Sign items pick list].[Form]![Item Category]
   
    
   Loop
 
Where are you calling this code from? So what is the SubForm and MainForm names? The problem might be you are not referring to the Forms control properly? Also you have used RecordSets, so to assign values to controls in other form, should you not take in like..
Code:
[Roll Out - Sign items added].Form!Code = rst.Fields("[Item Category]")
 
Last edited:
Thank you for the reply. I am copying from one sub form to another.

One is called [Roll Out - Sign items added] the other [Roll Out - Sign items pick list]

The main form is called [Roll Out - Site Form]

The code is on a onclick event of a button.

I changed the code you suggested but this still gives the same error
 
Where does the button Live? On Main form or [Roll Out - Sign items added] or [Roll Out - Sign items pick list]..

Are the two subforms [Roll Out - Sign items added] the other [Roll Out - Sign items pick list] in the same Main forms? Or the Subform [Roll Out - Sign items added] acts as the main form for [Roll Out - Sign items pick list]..
 
The button is on the main form.

The two sub forms are both located on the main form.

In effect i have two sub form datasheets side by side on a main form that i want to copy the field from one to the other.
 
Try this..
Code:
Private Sub buttonName_Click()
    Dim rst As DAO.Recordset
    Set rst = Me![Roll Out - Sign items pick list].Form.RecordSetClone
    Do While Not rst.EOF
        Me![Roll Out - Sign items added].Form!Code = rst.Fields("Item Category")
    Loop
    Set rst = Nothing
End Sub
 
I tried what you suggested changing my code to this:


Dim rst As DAO.Recordset
Set rst = Me![Roll Out - Sign items pick list].Form.RecordsetClone
Do While Not rst.EOF
Me![Roll Out - Sign items added].Form!Code = rst.Fields("Item Category")

rst.MoveNext
Loop
Set rst = Nothing


I added the movenext as it was infinate looping by the look of it.

It no longer gives me the error however it does not do anything (at least nothing visible).

Any further suggestions?

EDIT: After some further testing i found it was doing something - it is only copying the last entry in the datasheet and it will only do it once, if i click on the button again it does nothing?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom