Full Version: Using Command buttons with code to copy, paste and clear fields
UtterAccess Forums > Microsoft® Access > Access Forms
currently use a form which has three command buttons (and the following code):
These commands have always worked in pure Access databases. I am now using linked tables in SQl with an Access front end and the only button that functions properly is the clear button. The only difference I see is that in the sql tables the control source is strwho1, strwho2...etc..but the name is still who1, who2, who3...etc...
In the pure Access databases the control source and name have always been the same (who1,who2,...etc..
Any guidance would be appreciated. THis is so simple I feel I must be missing something very simple.
Copy Button
Private Sub Command147_Click()
varWho1 = Me.who1
varWho2 = Me.who2
varWho3 = Me.who3
varWho4 = Me.who4
varWho5 = Me.who5
varWho6 = Me.who6
End Sub
Paste Button
Private Sub Command149_Click()
Me.who1 = varWho1
Me.who2 = varWho2
Me.who3 = varWho3
Me.who4 = varWho4
Me.who5 = varWho5
Me.who6 = varWho6
End Sub
Clear Button:
Private Sub Command95_Click()
Me!who1 = Null
Me!who2 = Null
Me!who3 = Null
Me!who4 = Null
Me!who5 = Null
Me!who6 = Null
End Sub
What is the error message you are getting? Or what is the problem?
Looks like you COPY, (then go to a new record, I assume????) , then PASTE to duplicate a record????
A little more info.
I'm not getting an error message at all. Its simply not cutting and pasting (working). The clear button does work. Actually, when I hit the paste button it deletes the information in the combo boxes.
asically, I an entering data in 6 cascading combo boxes. This data is for pathological tissue diagnosis. This data is entered for each case(record). I want to use the copy, paste feature because many times multiple cases will have the same diagnosis.
You must be doing SOMETHING between the copy and the paste. (How would you know if they are working or not?)
Do you put something in the fields, then do a copy, then delete the info in the fields (or move to a new record?) , then paste to see if they show back up?
lso, where is varWho1, varWho2, ect, defined? Variables local to the form?
The reason that I'm asking all these things is that I have found that Access BE's perform slightly different than SQL BE's in some areas. As far as WHEN a value gets into the actual RECORD vs. when the values appear on the form.
For instance, in an ACCess FE/Access BE, when you move to a new record, as soon as you start typing into the record, the Autonumber field, will get generated and populated. Not so for the SQL (linked tables) backend. The autonumber gets generated when the update occurs.
So need to know a bit more details about your implementation.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.