Copy Paste in Access Form: Pls Help

IIVRglobal

New member
Local time
Today, 05:13
Joined
Feb 26, 2012
Messages
9
Hello Friends
I use access to create record of my patients and the daily treatment I give them. (attaching a file pic for quick reference)

Mostly my line of treatment with a patient remains same everyday. Hence I have to copy, paste every time to record fresh visit.

If some click button be created that could do entire action in just one click would be very useful. And my challenge is that I just know nothing about VBA than that it is possible thru it.

If someone can help me out, it will be very useful.

Thanks a lot
 

Attachments

  • Workbook Copy.JPG
    Workbook Copy.JPG
    83 KB · Views: 336
A really simple way is to use the Ctrl + Double Quote (Ctrl key + " key) keyboard short-cut to copy the value of the field from the previous record.

If you want to make it more automatic you could use the following code in the Form's On Current event;
Code:
Me.YourFieldName.DefaultValue = [URL="http://www.techonthenet.com/access/functions/domain/dlookup.php"]DLookup[/URL]("YourFieldName", "YourTableName", "YourRecordID = " & [URL="http://www.techonthenet.com/access/functions/domain/dmax.php"]DMax[/URL]("YourRecordID", "YourTableName"))
 
Last edited:
Thanks John
The shortcut U told Ctrl+" is useful but not applicable in most cases as line of treatment keeps on changing and in my records I sort Latest visit at top and oldest at bottom. Due to this it automatically copies oldest record.

About the code U gave seems what I wanted but couldn't find what U defined as

Form's On Current event

Hope U R not referring to "Default Value" in the table.

If U could help me further about this.

Thanks again
 
On Current is a form event, you will not find it at table level.

As a quick run down. Your tables store your data, and your user should have no direct interaction with the tables. Forms allow your user to interact with the data stored in the tables. Reports allow your user to create hard copy representations of the data. Whilst Queries allow you to manipulate the data for display in either forms or Reports.
 
Thanks John
I read the links U gave

But still unable to understand how & where to use the code.

I suppose this problem arises every time U deal with NOVICE like I am.

Pls help
Thanks again
 
Put your form into design view. Make sure there is a small black square in the box at the junction of the Horizontal and Vertical rulers. Select the Events on the properties window. Now go to the On Current event, select Event Procedure from the drop down list. Now click on the ellipsis button (that the little button with the three dots on it. A code wind will open. Copy and post the code I posted earlier into the window below the line that reads; Private Sub Form_Current() and above the line that reads; End Sub. Changing the code where I have used Your..., to match the reality of your DB.
 
Thanks John
I wanted to post value in "Marma" field in "Visit Record" table in "Marma Record" Form. "Sr" is the field thru which "Marma Record" & "Visit Record" tables are mutually related.

Hence,
I pasted the following code

Me.Marma.DefaultValue = DLookup("Marma", "Visit Record", "Sr = " & DMax("Sr", "Visit Record"))

But it gives error with above marked Marma

Can U Help further

Thanks again
 
Are you using that in the Main Form's On Current or the Sub Form's On Current event?
 
Thanks John for replying back

I actually used it on Main Form - The black dot U mention only appears in the main form

In sub-form only two things appear in event tab - "On enter" and "on Exit"

What do U suggest me to do?

Looking forward to hear from U.

Thanks a lot

I sincerely appreciate the effort U R putting in to help me get things done in order!
 
Just now I tried it with sub-form also.

The error is still there

Pls advise
 
Dear John
Pls find file attached.

Thanks for your help.
 
Last edited:
OK, I've had a look at your DB.

First up you might want to consider a naming protocol for your DB objects and controls, something along the lines of; TBL_TableName, FRM_FormName, QRY_QueryName etc. This will make it clear in your code the type of object that is being referred to. Also avoid using spaces and other special characters in the names of controls and objects, limit yourself to alpha and numeric characters and the underscore (_) .

Now before getting into the main point of my reply, a quick run down on the various DB Objects. Tables are for storing your data, and your user should not have direct interaction with the data at that level. Your Forms allow your user to view, input, edit and otherwise manipulate the data stored within the underlying tables. Queries allow you to manipulate your data for display to your user, in a meaningful manner, through, the filter of, either a Form or Report. Reports are used for creating a hard copy representation of your data for display purposes only.

Your form "Marma Records" has table "Visit Record" set as a Sub From :eek: so straight away I see that as a problem. However that is only minor, when we consider that you have no Parent/Child link between the two. And therefore no way to link a particular visit to a particular client.

Have a look at the various data models available here I'm sure that you will find one that will give you a kick start :)

In the mean time, I'll have a bit of a play in my sand box and see if I can create something that demonstrates the process we have been trying to get working in your DB.
 
Dear John
Thanks for descriptive mail.
Still reading Ur mail

Jut to share an info with U.

There is a field by the name of Sr (linked to Marma Record Table) in Visit Record table, that is hidden in the Subform.

Thanks a lot
 
Here's a sample DB showing how I might organise things.

Caveat emptor; it's going to need some substantial polishing :)
 

Attachments

Dear John
Were U able to find some solution to my problem.

Thanks a lot
 

Users who are viewing this thread

Back
Top Bottom