If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > How to pull/push a value from the current form to a Module using VBA

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Nov 2012
Posts: 8
How to pull/push a value from the current form to a Module using VBA

Using the code below I am able to open an explorer window from access and select most of a file path. The part I am not able to get is "LN" which is a field in my forms. I need to be able to pull the current LN number into my Modules file path. How do I do this? Is it easier to go by ID or the actual field I am looking for?


Code:
Function Loan_Folder_Search3()
      Dim rs              As Recordset
      Dim LN              As String
      Dim Client_Name     As String
      Dim RetVal          As String
      Dim LFPath          As String
            
      
      
      Set rs = CurrentDb.OpenRecordset("SELECT ID, LN, Client_Name FROM [Loan_Info_local]")
      LN = rs![LN]
      
      Client_Name = rs![Client_Name]
            
      Select Case Client_Name
      
      Case "Bank of David, N.A."
        LFPath = "\\MAXSERVER\Max Default\BOD\"
        RetVal = Shell("explorer.exe " & LFPath & LN, vbNormalFocus)
        
      End Select
      
      rs.Close
      Set rs = Nothing
End FunctionCurrently, it keeps pulling the first reccord, no matter what reccord I'm on.
Thank you,
David92595
Reply With Quote
  #2 (permalink)  
Old
(Making Your Life Easy)
 
Join Date: Feb 2004
Location: New Zealand
Posts: 1,275
why not just pass the LN
to the function

Function Loan_Folder_Search3(LN)

delete the Dim LN

some where in your form code

aaa = Loan_Folder_Search3(formtextname)
__________________
hope this help

See clear as mud


StePhan McKillen
the aim is store once, not store multiple times
Remember... Optimize 'til you die!
Progaming environment:
Access based on my own environment: DAO3.6/A97/A2000/A2003
VB based on my own environment: vb6 sp5
ASP based on my own environment: 5.6
VB-NET based on my own environment started 2007
SQL-2005 based on my own environment started 2008
MYLE
Reply With Quote
  #3 (permalink)  
Old
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 12,306
Myle's suggestion is the one id go with...

But for the record
To pull a value
myvariable = forms!thatformname!thatcontrolname
To push a value
forms!thatformname!thatvariable = thatvariable
You can do this in forms or reports
You can use controls, variables or objects on either side and you are not constrained to use on both sides. So you can set a control using a variable.
__________________
Is taking part in the 'Distinguished Gentlemans' ride. Being neither distinguished nor a gentleman, but I am keen to raise funds for Prostrate Cancer research. At present I'm threatening to ride a Norton 961 wearing a kilt. If you would like to contribute to Prostrate Cancer research then please consider donating via this page:-
http://www.gentlemansride.com/rider/healdem
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Nov 2012
Posts: 8
Thank you for your suggestion. I have implimented it in our database and the bosses seam to like it.

Thank you,
David92595
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On