Can anyone help with this bit of coding? What I am trying to do is copy contents of a text box (Address1) in one form, then go into another form and paste the information into another text box (Form2 Address1). Return to the original form copy the next text box (Address2) and return to the next form and paste into Form2 Address2.
This is repeated for Address3, Address4, Address5 and Postcode.
The code below work fine with no problems until there is a blank space in one of the Address text boxes i.e.
Address1: Fred Bloggs House
Address2: Blogg Street
Address3: Blogg City
Address4: Bloggshire
Address5:
Postcode: BL0 0GG
It does not then go past the blank field and only copies upto Address4.
Can anyone get me past this blank please!
The code I have wrote is
Private Sub Command20_Click()
Dim stDocName As String
Dim stLinkCriteria As String
On Error GoTo copypaste_copypaste_Err
stDocNameContact = "Contact Form"
stDocNameAddress = "Address List"
DoCmd.GoToControl "[Address 1]"
DoCmd.RunCommand acCmdCopy
DoCmd.OpenForm stDocNameContact, , , stLinkCriteria
DoCmd.GoToControl "[Address 1]"
DoCmd.RunCommand acCmdPaste
DoCmd.OpenForm stDocNameAddress, , , stLinkCriteria
DoCmd.GoToControl "[Address 2]"
DoCmd.RunCommand acCmdCopy
DoCmd.OpenForm stDocNameContact, , , stLinkCriteria
DoCmd.GoToControl "[Address 2]"
DoCmd.RunCommand acCmdPaste
DoCmd.OpenForm stDocNameAddress, , , stLinkCriteria
DoCmd.GoToControl "[Address 3]"
DoCmd.RunCommand acCmdCopy
DoCmd.OpenForm stDocNameContact, , , stLinkCriteria
DoCmd.GoToControl "[Address 3]"
DoCmd.RunCommand acCmdPaste
DoCmd.OpenForm stDocNameAddress, , , stLinkCriteria
DoCmd.GoToControl "[Address 4]"
DoCmd.RunCommand acCmdCopy
DoCmd.OpenForm stDocNameContact, , , stLinkCriteria
DoCmd.GoToControl "[Address 4]"
DoCmd.RunCommand acCmdPaste
DoCmd.OpenForm stDocNameAddress, , , stLinkCriteria
DoCmd.GoToControl "[Address 5]"
DoCmd.RunCommand acCmdCopy
DoCmd.OpenForm stDocNameContact, , , stLinkCriteria
DoCmd.GoToControl "[Address 5]"
DoCmd.RunCommand acCmdPaste
copypaste_copypaste_Err:
MsgBox "Address Copied OK "
End Sub
Thanks for your time
BH
This is repeated for Address3, Address4, Address5 and Postcode.
The code below work fine with no problems until there is a blank space in one of the Address text boxes i.e.
Address1: Fred Bloggs House
Address2: Blogg Street
Address3: Blogg City
Address4: Bloggshire
Address5:
Postcode: BL0 0GG
It does not then go past the blank field and only copies upto Address4.
Can anyone get me past this blank please!
The code I have wrote is
Private Sub Command20_Click()
Dim stDocName As String
Dim stLinkCriteria As String
On Error GoTo copypaste_copypaste_Err
stDocNameContact = "Contact Form"
stDocNameAddress = "Address List"
DoCmd.GoToControl "[Address 1]"
DoCmd.RunCommand acCmdCopy
DoCmd.OpenForm stDocNameContact, , , stLinkCriteria
DoCmd.GoToControl "[Address 1]"
DoCmd.RunCommand acCmdPaste
DoCmd.OpenForm stDocNameAddress, , , stLinkCriteria
DoCmd.GoToControl "[Address 2]"
DoCmd.RunCommand acCmdCopy
DoCmd.OpenForm stDocNameContact, , , stLinkCriteria
DoCmd.GoToControl "[Address 2]"
DoCmd.RunCommand acCmdPaste
DoCmd.OpenForm stDocNameAddress, , , stLinkCriteria
DoCmd.GoToControl "[Address 3]"
DoCmd.RunCommand acCmdCopy
DoCmd.OpenForm stDocNameContact, , , stLinkCriteria
DoCmd.GoToControl "[Address 3]"
DoCmd.RunCommand acCmdPaste
DoCmd.OpenForm stDocNameAddress, , , stLinkCriteria
DoCmd.GoToControl "[Address 4]"
DoCmd.RunCommand acCmdCopy
DoCmd.OpenForm stDocNameContact, , , stLinkCriteria
DoCmd.GoToControl "[Address 4]"
DoCmd.RunCommand acCmdPaste
DoCmd.OpenForm stDocNameAddress, , , stLinkCriteria
DoCmd.GoToControl "[Address 5]"
DoCmd.RunCommand acCmdCopy
DoCmd.OpenForm stDocNameContact, , , stLinkCriteria
DoCmd.GoToControl "[Address 5]"
DoCmd.RunCommand acCmdPaste
copypaste_copypaste_Err:
MsgBox "Address Copied OK "
End Sub
Thanks for your time
BH