Hi Folks,
I'm trying to pass a string between two different forms in ACCESS with code, and I'm having some difficulty tracking down the proper way to do this. Assistance in completing this task is greatly appreciated.. Thanks in advance! - Jordan
Here's what I want to accomplish:
Form 1: is a text input box.
Click a button to launch Form 2
Form 2:
Click a button to take text from several input boxes and concatenate in one variable, then pass (or store) the variable for retrevial in Form 1
Form 1:
Insert text from variable at cursor in text box..
Here's what I've got so far:
Form 1:
Option Explicit
'========================================================================
'Open Form Code (built by Access)
'------------------------------------------------------------------------
Private Sub cmdCJAInsertHyperlink_Click()
On Error GoTo Err_cmdCJAInsertHyperlink_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmCJANewLink"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdCJAInsertHyperlink_Click:
Exit Sub
Err_cmdCJAInsertHyperlink_Click:
MsgBox Err.Description
Resume Exit_cmdCJAInsertHyperlink_Click
End Sub
Form 2:
Option Explicit
Private Sub cmdCJANewLink_Click()
'=======================================================================
'Define variables in Memory
'-----------------------------------------------------------------------
Dim strLinkURL As String
Dim strLinkMouseOver As String
Dim strLinkTarget As String
Dim strLinkText As String
Dim strFinalLink As String
Dim strFinalLink As String
'=======================================================================
'Populate variables with form data
'-----------------------------------------------------------------------
strLinkURL = Form_frmCJANewLink.txtCJAURL.Value
strLinkMouseOver = Form_frmCJANewLink.txtCJAMouseOver.Value
strLinkTarget = Form_frmCJANewLink.cboCJATarget.Value
'=======================================================================
'Build Final Link String
'-----------------------------------------------------------------------
strFinalLink = "<a" & vbCrLf & _
"href=" & chr(34) & strLinkURL & chr(34) & vbCrLf & _
"target=" & chr(34) & strLinkTarget & chr(34) & vbCrLf & _
"onmouseover=" & chr(34) & chr(34) & "top.window.status='" & strLinkMouseOver & "'; return true" & chr(34) & chr(34) & vbCrLf & _
"onmouseout=" & chr(34) & chr(34) & "top.window.status=''; return true" & chr(34) & chr(34) & ">" & strLinkText & "</a>"
'========================================================================
'Close Form Code (built by Access)
'------------------------------------------------------------------------
On Error GoTo Err_cmdCJANewLink_Click
DoCmd.Close
Exit_cmdCJANewLink_Click:
Exit Sub
Err_cmdCJANewLink_Click:
MsgBox Err.Description
Resume Exit_cmdCJANewLink_Click
End Sub
Private Sub cmdCJACancel_Click()
On Error GoTo Err_cmdCJACancel_Click
DoCmd.Close
Exit_cmdCJACancel_Click:
Exit Sub
Err_cmdCJACancel_Click:
MsgBox Err.Description
Resume Exit_cmdCJACancel_Click
End Sub