Recrod Save as

mithani

Registered User.
Local time
Today, 23:11
Joined
May 11, 2007
Messages
291
Hi all,

I tried a lot but couldn't figure it out.

I have a form with subform. I can saving my record and recall for edit purpose. What I am looking for, when I call any saved record, I want option for SAVE AS. Means I can keep all information same but make some changes and save as a new record.

Please help me guys.

Mithani
 
Well, because changes are automatically updated in bound forms, maybe you could add a button?

Something that says "Edit Record", maybe? Then, on the click event, use some Access commands. Here are a few that might be useful: accmdcopyrecord, accmdpaste, docmd.gotorecord. See where I'm going with this?
 
thanks ajetrumpet, will this help me with?

1. Call my saved record,
2. accmdcopyrecord,
3. press new record button
4. accmdpaste
5. change project code and save.

Any sample form... Thanks a lot.

mithani
 
thanks ajetrumpet, will this help me with?

1. Call my saved record,
2. accmdcopyrecord,
3. press new record button
4. accmdpaste
5. change project code and save.
Yes, that will do something at least. I just have one question for you: Do you understand the process that you have just written? Do you know what it will do for you? If you don't, why don't you experiment with it and see! :) What you want to do shouldn't take too much work.

If you want a sample, maybe I can post one up here. Let me know if you would like to see one.
 
Hi ajetrumpet

Thanks for your reply mate.

We have several projects and what I am looking for is to save same templates. Whenever I get a new project, I can call my old saved template and change project name, quantity, sizes and save as a new record.

I am not very good with access. I would appreciate if you could guide me and send me a sample if possible.

Thanks a lot

mithani
 
One way of doing this easliy is to have record selectors set to yes on your form. This will allow you to copy the record and create a new record and paste the one you copied into it and leave the old record unchanged. No coding just a couple of mouse clicks

Gary
 
One way of doing this easliy is to have record selectors set to yes on your form. This will allow you to copy the record and create a new record and paste the one you copied into it and leave the old record unchanged. No coding just a couple of mouse clicks
I think it might be a bit more involved than that, although it doesn't have to be (I don't think)...
We have several projects and what I am looking for is to save same templates. Whenever I get a new project, I can call my old saved template and change project name, quantity, sizes and save as a new record.
Well, I don't have a very good picture in my mind here. How about you guide me first? Can you send me an image or anything? Any written notes? Any ideas? Or, do I just have to go off of what we have said so far?

That might be a bit difficult. And, I don't really have the time to do that, so any help you can give me to jumpstart things will certainly speed up the process...
 
All you're really talking about here is copying a record, then changing some of its data!

  1. Place a command button on your form
  2. When the Wizard comes up select Record Operations and Duplicate Record
  3. Hit Next and follow the Wizard's directions
You're done!

Go to the record you're targeting, click your button, you'll be taken to the new record (with the data filled in) change the appropriate field(s) and you're done!
 
It really is! You do have to change whatever the Primary Key is, or any other data that's set to No Dups, but you'd have to do that no matter how you created the record!
 
Hi missinglinq,

When I press duplicate button, error comes "The changes you requested to the table were not sucessful because they would create duplicate value in the index......."

Even if I change primary key first and than press duplicate button, still same error comes. Any idea.

Hi ajertrumpet,

Please see attached jpg. Only drawing # should be change and rest everything I want to create duplicate record.

Thanks

mithani
 

Attachments

  • estimating2.JPG
    estimating2.JPG
    94.3 KB · Views: 155
Hi ajertrumpet,

Please see attached jpg. Only drawing # should be change and rest everything I want to create duplicate record.
Mithani,

How many subforms do you have in that picture? You can't just copy and paste, for the reasons already illustrated by the message you got about the primary key violations.

What are the primary keys? Is there just one? Is it the Drawing #?

Regardless of what it is, if you have subforms involved here, and you want all of the data that you see in the picture, included in the new record, you're going to have to work with recordsets in the coding...
 
Sorry to take so long to get back to you! Been sick and off-line that last couple of days. I don't understand why you're having this problem. You should only be getting this message if you do something to save the new record (move to another/new record, close the form) and you haven't changed the Primary Key or other fields that are set to Indexed (no duplicates.) Merely copying the data to a new record shouldn't do it, any more than entering the same data by hand would do it! Until you save it, Access has no way to know that data is a duplicate.
 
Hi ajetrumpet,

Only one subform is there. Drawing # is a primary key.

Please correct me if I am wronge, you mean instead of working directely with table, should set recordset. So when I make duplicate and change primary key, should press SAVE buttton to save in my table.

If this is a case, do you have any example how to use recordset.:

Thanks

mithani
 
Mithani,

I don't know any other way to do this. The only stumbling block you have is that stupid Primary Key Value! So, you need a way to copy all of the main form's data except the Primary Key value. Why don't you just do this...
Code:
Dim c As Control, var(40) As Variant, i As Integer

i = 0

  For eachc In Me.controls
    If typeof c Is combobox Or typeof c Is TextBox Then
      If Not c.name= "drawing #" then
        var(i) = c
          i = i + 1
      end If
    end If
  Next c

DoCmd.gotorecorddataform, Me.name, acnewrec

i = 0

  For Each c In Me.controls
    If typeof c Is ComboBox Or typeof c Is textbox Then
      If Not c.Name = "drawing #" then
        c = var(i)
          i = i + 1
      End If
    End If
  Next c
I used a 40 element array. Hopefully, that's less than the number of controls you have on that page. At least this will get the job done!!! :)

Keep in mind: that will not copy any of the values you have in the subform datasheet, but you don't want any of those values, right?

If you do, I'm thinking you will have to use a recordset...
 
Hi Ajetrumpet,

Data in subform is a standard combination of a construction drawing. I want subform data to be copied as well. I think the best way to do this through recordset. What do you say.

thanks a lot

mithani
 
Yeah, probably so.

You won't know how to do it though unless you know if those records in the middle of the picture are actually in a subform, or in a child table. Do you know?

If the records appeared automatically when you created the main form, then it is a child table, probably linked to the main form's data on the PK. If you inserted an actual object in there, then it is a subform.

It will be a lot easier to do this if it is indeed a subform object...
 

Users who are viewing this thread

Back
Top Bottom