User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS Access and FileMaker Pro section within the Web Development category of DaniWeb, a massive community of 397,797 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,360 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS Access and FileMaker Pro advertiser:
Views: 5848 | Replies: 3
Reply
Join Date: Nov 2005
Posts: 10
Reputation: cavok is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
cavok cavok is offline Offline
Newbie Poster

Help ACCESS - Need help passing a string between forms

  #1  
Oct 23rd, 2006
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2004
Posts: 15
Reputation: Uncle Gizmo is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
Uncle Gizmo Uncle Gizmo is offline Offline
Newbie Poster

Re: ACCESS - Need help passing a string between forms

  #2  
Nov 7th, 2006
Here's one I made earlier! This may give you an idea of a different way of going about it.

Cheers Tony
Attached Files
File Type: zip OpenAfromBTransferInfo.zip (50.9 KB, 117 views)
Reply With Quote  
Join Date: Nov 2005
Posts: 10
Reputation: cavok is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
cavok cavok is offline Offline
Newbie Poster

Re: ACCESS - Need help passing a string between forms

  #3  
Nov 13th, 2006
Originally Posted by Uncle Gizmo View Post
Here's one I made earlier! This may give you an idea of a different way of going about it.
Cheers Tony



Thanks a bunch Tony, I've had a look at it this evening, and I'm still trying to make it work.. Is it possible for me to use this method to transfer the contents of a variable? I've tried doing this with no result..

Also, if anyone has any thoughts about how I'd paste the resulting text (from a variable) at the cursor, I'd muchly appreciate..

(I've done away with your WITH statement, because I only want to transfer the variable containing the concatenated text. )

frmCJAJournaL.txtCJALinkTest.Text = strFinalLink

On the original form, I've tried to drop it into a text box and a message box with no result and I'm really not sure how to handle this..

Your thoughts are appreciated.

Thanks again, and sorry for the late reply, I've been out of town working, and haven't been checking email!

J
Last edited by cavok : Nov 13th, 2006 at 7:42 am.
Reply With Quote  
Join Date: Mar 2004
Posts: 15
Reputation: Uncle Gizmo is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
Uncle Gizmo Uncle Gizmo is offline Offline
Newbie Poster

Re: ACCESS - Need help passing a string between forms

  #4  
Nov 20th, 2006
Modify this line As shown below and it passes the variable contents....

.addrb1 = strDocName

I am not sure what you mean?
>>>how I'd paste the resulting text (from a variable) at the cursor<<<

do you mean paste the contents of the clipboard? If you do, this is possible with code.

btw I only got your message this morning 20 November 2006, there appears to be a considerable delay on this web site for sending out messages! thought you should know.
Last edited by Uncle Gizmo : Nov 20th, 2006 at 6:53 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MS Access and FileMaker Pro Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MS Access and FileMaker Pro Forum

All times are GMT -4. The time now is 5:49 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC