Copy / Paste buttons and global variables

OZmc

Registered User.
Local time
Today, 11:32
Joined
Dec 14, 2012
Messages
27
Hi. I am a novice with VBA, but I know a fair amount of C++ and Python.

I am trying to create a Copy button that copies the values in set of fields in one form and a paste button that when called will enter the data into another set of fields in another form.

I was thinking global variables would help here.

Ie.

Global = var1
Global = var2
Global = var3

Private sub command 01_click()
var1 = field 1
var2 = field 2
var3 = filed 3

-----------

private sub command 02_Click()
field 1 = var1
field 2 = var2
field 3 = var3


Can someone help me with the coding? I dont know the syntax for global variables. I am tying to put the golbal variables in the specific forms code and im getting an error.
 
In a standard module, this type of thing:

Public curPayment As Currency

using your desired name and data type of course.
 
Great thanks!

I have a module setup with:

Public strVar1 As String
Public strVar2 As String
Public strVar3 As String
Public strVar4 As String
Public strVar5 As String
---------------------------------------------------
then on the form I have:

Private Sub Command90_Click()
Var1 = [field name1]
Var2 = [field name2]
Var3 = [Field name3]
Var4 = [field name 4]
Var5 = [field name 5]
_________________________________________

Private Sub Command91_Click()
[field name 1] = Var1
[field name 2] = Var2
[field name 3] = Var3
[field name 4] = Var4
[field name 5] = Var5


but i get an error:
field 'form_name.field name 1' cannot be a zero-lenth string.


I entered in data before i clicked copy so there should be a string there....
 
For starters, I'd use the variable names that you declared. ;)
 

Users who are viewing this thread

Back
Top Bottom