Pass Variable To Other Form Code
How can i get a variable from code in form1 in code in form2?
code in form1:
code in form2:
Dim i As Integer
Dim s As String
i = FreeFile()
Open filename For Input As #i
Do Until EOF(i)
Line Input #i, s
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Pass Variable Onto Other Form
I was wondering if anyone knew how to pass a variable onto another form. Also the variable needs to keep its current Value.
Any help would be grateful
How Do U Pass Variable To Other Sub Form
I have three form, on is a detail form, location form, main form
I have a variable in the main for which is set to
public name as boolean
and now if i wanted to get that booleam from the main form in the detail form, I would do something like this:
'from Detail form
dim names as booloean
names = CType(Me.Owner, frmMain).name
now that is clearly a get method
but instead of get is there a way to pass values stored in the main form into a method in the sub form (detail) ?
one of the sub form method is like this
Public sub NamePor (ByVal name As Boolean)
Pass A Variable From One Form To Another?
How would you pass a variable from one form to another? The only thing I can think of is to setup some global variables. I am trying to keep the project clean and that would seam to waste a lot of memory.
Pass A Variable From One Form To Another
I have 2 forms named frm1 and frm2. frm1 is used to get the name of the user which is stored in txtName.
I want to pass txtName.text to frm2 to do some processing and finally displaying the name of the user on frm2.
How can I do that ?
Who Can I Pass A Form String Name To A Form Object Variable?
Who can I pass a form string name to a form object variable?
I have all forms technical name in my database table I want to get form name from table and try to open its. But I can’t do it. Please! If u know about this problem help me.
My sample Code is:
Dim Formstr As String
Dim FormObj As Form
Formstr = "Form2" '// i will get this string from database here its fixed
Set FormObj = Formstr
When I try to use this Code System Give me Error Message
Edited by - AbbydonKrafts on 3/29/2007 6:16:34 AM
How Do I Pass A Variable From The Form To The Module?
I know this is simple, but I'm still getting the hang of this. My code is posted. I'm wanting to pass the variable strFilepath to my module. How do I write the calls in the ()'s?
I've found Call RunProgram(strFilepath) is wrong. I have the variable right now in the module under Public strFilepath As String.
Private Sub Form_Load()
FileLabel.Caption = ""
FileLabel.ForeColor = vbRed
On Error GoTo skipdrive
Drive1.Drive = "O:"
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
Private Sub Dir1_Change()
File1.Path = Dir1.Path
FileLabel.Caption = ""
Private Sub File1_Click()
Dim strFile As String
Dim i As Integer
On Error GoTo NothingSelected
'Find the first selected occurance in the list.
For i = 0 To File1.ListCount - 1
If File1.Selected(i) Then
strFile = File1.List(i)
FileLabel.Caption = strFile
'Save the file path of the file picked.
strFilepath = Dir1.Path & "" & strFile
Private Sub Command_Run_Click()
Dim lPointer As Long
'Save the current pointer.
lPointer = Me.MousePointer
Me.MousePointer = vbHourglass
[b]Call RunProgram(strFilepath)[/b] 'Me.File1, Me.Dir1)
'Return the pointer.
Me.MousePointer = lPointer
Private Sub Command_Exit_Click()
'Don't use END to exit application!
Pass Variable To Form Load
Hello, can somone tell me how to pass a variable to a form load from another procedure?
If working with two procedures, I'd do this:
Sub MainCall Sub Procedure(Call_ID)End Sub Sub Procedure (Call_ID as string)'StuffEnd Sub
I want to do the same thing except with a form:
Sub MainCall Form(Call_ID)End Sub Private Sub Form_Load(Call_ID as string)'StuffEnd Sub'This procedure won't work. I want to pass Call_ID from main procedure to the form load.
I'd rather pass the value than declare it public. Can someone tell me what I am doing wrong? Thanks in advance.
Why Can't I Pass A String Variable From Form1 To Form2 In The Attached Code???
What am I doing wrong. I can pass the strings to Form2 if I refer to the strings as Form1.string. But Form2 will also need to process data from other forms, e.g. Form3.
Form2 has a winsock control to send the data to an E-mail address.
Form1: optSelect is the string I'm trying to pass without the Form1. prefix. It's the description of which option button was selected.
Public txtTo As String
Public txtMsg As String
Public txtSubject As String
Public txtCC As String
Public optSelect As String
Sub cmdSend_Click(Index As Integer)
If optSelect = "" Then
MsgBox ("You must select a discrepancy type.")
Sub optDiscr_Click(Index As Integer)
If optDiscr(0).Value = True Then
optSelect = "Discrepancy Report - Transfer"
ElseIf optDiscr(1).Value = True Then
optSelect = "Discrepancy Report - Inventory Level"
ElseIf optDiscr(2).Value = True Then
optSelect = "Discrepancy Report - Replenishment"
ElseIf optDiscr(3).Value = True Then
optSelect = "Discrepancy Report - Core Returns"
ElseIf optDiscr(4).Value = True Then
optSelect = "Discrepancy Report - New Defective"
ElseIf optDiscr(5).Value = True Then
optSelect = "Discrepancy Report - Other"
txtWhse.Text = UCase(txtWhse.Text)
Form2: All the strings prefaced with Form1. come through ok. The string optSelect doesn't. It shows "Empty" when running in Debug.
txtTo = "firstname.lastname@example.org"
txtMsg = "Whse " & Form1.txtWhse & vbCrLf & _
"Name " & Form1.txtName & vbCrLf & vbCrLf & _
"Item " & Form1.txtPart & vbCrLf & vbCrLf & _
"Discrepancy" & vbCrLf & Form1.txtDisc
txtSubject = optSelect
Text1.Text = txtSubject & vbCrLf & _
"To: " & txtTo & vbCrLf & _
Again, as always
A computer is a tool, not a toy.
Pass Variable Content From Form To Form
I am trying to pass a variable that I populated in a form and then closed that form, open a new form and use that variables content in the new form all in the same application. Please help if you can, thanx
How Do I Pass This Variable?
function NextPage( page )
document.PageForm.page.value = page;
I go to this page, grab some info from here:
by using this code:
c = wb.Document.Body.innerHTML
i = InStr(c, ">Next </A>")
If i = 0 Then
i = InStrRev(c, "Page(", i)
c = Mid(c, i + 5)
i = InStr(c, ")")
c = Left(c, i - 1)
c = Replace(c, "'", "")
wb.Document.All("page").Value = c
tmrTimeout.Enabled = True: Recollect = True
my issue is that it doesn't pull the correct variable and put it into wb.Document.All("page").Value and just keeps cycling and giving me the same page and not moving on to the next.....something I'm doing wrong?
Pass A Variable Name To A Sub
How can I pass a Variable name to a public sub, for example
Public Hdata As StringPublic Wdata as String Public sub Getthis(MyVar as Variable) MyVar = "This Data" End Sub Private Sub Form_Load() Getthis("Hdata") End Sub
So in this it would assign the string "This Data" to the HData variable whos name is stored in the MyVar variable.
Can this be done?
How To Pass Variable
I have a saved a variable slot01 = blank
Now I want to pass that when I am displaying error message and writing log file
ErrorMsg = "Error on opening" & Slot01 & ""
That did not work...how can I pass the variable of Slot01 in the ErrorMsg.
I also write logfile..
Call log("The" & Slot01 & "has passed)
Call log("The" & Slot01 & " did not pass)
How Do I Pass A Variable To A Sub?
I'm having trouble passing a variable to my sub statement and I can't figure out why.
Here's my code:
Sub LockAllControls(frm As Form)
Dim c As Control
For Each c In frm.Controls
If TypeOf c Is CommandButton Then
c.Enabled = False
how do I declare frm from within a call to the sub?
For example I want to call this sub from within another sub but it won't let me pass a form name for some reason.
I've been trying this to no avail: (I get a type mismatch for some reason)
Private Sub mnuViewEmployee_Click()
How Do I Pass A Variable?
Private Sub Label1_MouseDown(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button = vbRightButton) Then
On mnuCardMenu I click mnuCopyFile
Private Sub mnuCopyFile_Click()
Here I need to know the 'index' number.
Pass Variable To A DLL
Is it possible to pass a variable to a DLL?
Here's what I wanna do:
I have a variable in my project. I wanna pass that variable to a DLL ( actually a class module in a DLL), so that a certain property can be set correctly.
'-----------------------------'In current projectglobalAccount = "XYZ"'---------------------------- 'In DLL Private Sub Class_Initialize() 'pass variable in here if globalAccount = "XYZ" then BillingCode = "123" else BillingCode = "456" end if End Sub
Thanks in advance.
How To Pass A Variable? Please Help
I have a certain value getting from the text boxes, I need to store them like this.
temp = text1.text
Then I need to store it in another variable
Test = "C: emp"
When I pass Test Variable in the function instead of getting the value stored in the temp I am getting it as C: emp, How Can I get the Value which is stored in Temp, Any help will be appreciated.
How Do I Pass A Variable??
Good day to everyone. I'm using MS Access 2002 to do a database, and am working on a code that quite simply pops the user info up on a MsgBox command. For example, when the user pulls up the record of Bob Smith, and wants extended info, the "MORE INFO" button is clicked, and Bob Smith's address, phone, email, etc all pop up in a VB codebox. The problem I'm having is how to let VB know which record is currently on screen. Whenever the MsgBox is used, it puts the 1st record's info up, not the record that is currently on screen. Is there a way I can pass some sort of variable to VB so that the correct info is pulled up?
Variable SQL Pass-through Query
I am not much of an Access guy, mostly VB, so I'm asking this here on behalf of one of my users. He has a SQL Pass-through query as follows:
SELECT PARTMAST.PRDESC, PARTMAST.PRSTPK, PARTMAST.PRGRUP, MRSHIST.MRITEM, MRSHIST.MRDATE, MRSHIST.MRWRKC, MRSHIST.MRSHFT, MRSHIST.MRPRIM, CUSSPEC.CSHCUS, CUSSPEC.CSHPRT, CUSSPEC.CSFCM1, CUSSPEC.CSFCM2, CUSSPEC.CSMSTL, CUSSPEC.CSMCM1, CUSSPEC.CSMCM2, CUSSPEC.CSTNSK
FROM S105T1TM.FILES.CUSSPEC CUSSPEC, S105T1TM.AMFLIBH.MRSHIST MRSHIST, S105T1TM.FILES.PARTMAST PARTMAST
WHERE MRSHIST.MRITEM = PARTMAST.SPITEM AND CUSSPEC.CSHPRT = PARTMAST.PRPART AND ((MRSHIST.MRDATE Between 20031001 AND 20031002) AND (MRSHIST.MRWRKC In ('1002','1003','1004','1005','1007','1008','1206')))
The date area in there (MRSHIST.MRDATE Between...) is always one day apart. Right now he manually puts this information in. Is there a way to set up two date variables, one equal to Now() and the other equal to DateAdd(Now, "d", -1) and put those in the statement so that it can automatically generate the report? I don't even know if DateAdd is a valid VBScript function, but that's how I'd do it in Visual Basic.
Any assistance is appreciated. Thanks ahead of time.
Pass Variable From Word To VB
I have a word document and in it there is a button that runs a VB program that grabs attachments and creates a basic e-mail including the word document.
My problem is the program needs to check and make sure the word document is saved and not still the template. Second it needs to check the folder where the document is saved to see if there is a valid .pdf to also attach.
I can make this real simple, the first 9 characters of the saved word name is the folder name. So I just need a way to pass the word file name to my vb program at execution. Once I get it in VB I can do all the manapulation to the string to get the folder name.
Hope this makes sense, thanks.
Pass Variable To A Cell
Can you pass a vba variable to a cell?
I have a sheet that has 5 identical sections for 5 different sets of data. At run time, I make a datasheet for each set of data. I use two vba variables, we will call them SetNumber and ColumnsPerSet to figure out what column to work in (the 5 sets are set up in different columns). Everything works great.
The problem is, (found out after the fact) they want the value linked to the first sheet so only changes are made in one place.
Can I make an equation in a cell that says pull from cell((SetNumber * ColumnsPerController)-ColumnsPerController, X) if so, would I define those variables in the sheet etc.
I am kinda at a loss for where to go from here.
Thanks in advance for the help.
How To Pass Variable Into Ado.fields!?
i have a table in database which has fields like 9996,8050,5600...
. i'm writting a program to get data from selected field like 9996 and 8050 only. i have put the two field's name into an array.
my question is how to pass field's name into ado.Fields![m]?
For k = 1 To UBound(vArray, 1)
If vArray(k, 0) <> "" Then
m = vArray(k,0) '--9996
vArray(k, 2) = adoWip.Fields![m]
let say vArray(1,0) is 9996
and vArray(2,0) is 8050
Item cannot be found in the collection corresponding to the requested name or ordinal.
please help. thanks
Pass Variable Between Programs
How would I pass a variable between two of the same of my programs.
For Example: I have an mp3 player that plays songs.
When another version is started, I want it to check if another instance is running. I can do that much.
If there are two instances running then I want the second instance to pass the song name to the first and then kill itself.
How To Pass A Variable To An Event
How do I pass a value from one event to another. For example I have an Index in code in a got focus event for a field and I need this same Index to be passed to a command button event so I can process that index in that code
Pass Variable To Query...
I have a VB report based on an Access db query. I have created a form where the user can input a date, and search a field based on that date. Then all records corresponding to the date entered would display in the report. I saw a post awhile back that covered this but I can't find it now. How do I go about passing a variable to search a db query and then return the records on a report? If I remember correctly I have to create a reference to ADOX 2.5 For DLL and Security. Here is what I have for code so far.
QUERY being the name of my query.
Private Sub cmdEnter_Click()
.DataSource = "SELECT * FROM QUERY WHERE CourtDate ='" & txtDate1.Text & "'"
Any help would be great!
Pass A Variable Between Executables?
I have an application that is currently using two EXEs. Is it possible to send a variable from one EXE to the other? I have text box as part of one EXE that I would like to populate with different messages depending on what the other EXE does. Combining the two EXEs isn't a possibility at this point.
Pass An Integer Variable To Vb6
Is it possible to pass a variable from a form in a different project with vb.net to a form in vb6?? If so can someone please give me an example
Please help me out cos its very urgent for me. Many thanks.
Pass Variable From One Program To Another
Hi, I have two programs I have made. When the Program A opens, it shells Program B to open. Is there a way I can let Program B know the app.path of the program that opened it?
Pass Variable To A Datareport
How can I pass a string variable to a datareport? I have a label called "lblAddress", and I want to parse the customer's address so it looks more like:
123 Some Street, SomeTown 12345
123 Some Street SomeTown 12345
I know how to do the parsing bit, but I can't find how to get it into the datareport.
Thank you for your help,
Word2000 Pass Variable
I'm trying to create a button to open a Word 2000 document and pass along a variable to a macro in Word.
This is how it was done with Word Basic.
Dim WordObj as Object
Dim strDotName as string
Dim strSelect as String
'''txtProjectID is a text box on the form
Set strDotName = "test.dot"
Set WordObj = CreateObject("Word.Basic")
WordObj.FileNew ("c:program filesmicrosoft office emplates" & strDotName)
strSelect = txtProjectID
WordObj.SetFormResult "Project_IDfield", strSelect, 1
WordObj.ToolsMacro "FillForm", True
And the Word module. The mailmergeopendatasource was slightly altered ( <<path>>).
Public Sub MAIN()
Project_ID$ = WordBasic.[GetFormResult$]("Project_IDfield")
sqlstr$ = "SELECT * FROM [tblAppendProject] WHERE (([ProjectID] = '" + Project_ID$ + "'))"
WordBasic.MailMergeOpenDataSource Name:="<<<path>>util.mdb", ConfirmConversions:=0, ReadOnly:=0, LinkToSource:=1, AddToMru:=0, PasswordDoc:="", PasswordDot:="", Revert:=0, WritePasswordDoc:="", WritePasswordDot:="", Connection:="TABLE tblAppendProject", SQLStatement:=sqlstr$, SQLStatement1:=""
WordBasic.MailMerge CheckErrors:=1, Destination:=0, MergeRecords:=0, From:="", To:="", Suppression:=1, MailMerge:=1, MailSubject:="", MailAsAttachment:=0, MailAddress:=""
Any suggestions on how to do this in 2000?
Call Exe And Pass Variable
I developed an application on Microsoft Access 2000. I want to call a sub program which developed on Visual Basic. I wonder how do i call the Sub program? And pass the Log in ID variable from Microsoft Access 2000 application to the Sub program?
How Do I Pass Variable In PUT Command
I am trying the following code, but it will not send the File:
Private Sub cmdSend_Click()
Dim strFileName As String, strFileTitle As String
strFileName = CommonDialog1.FileName
strFileTitle = CommonDialog1.FileTitle
.Protocol = icFTP
.URL = "xxx.xxx.xxx.xxx"
.UserName = "xxx"
.Password = "xxx"
.Execute , "PUT " & strFileName & " " & strFileTitle
x = unique address, username, password
*If I forget the string variables and just type the text into the code of where it should go then it works fine.
Can someone please help?
[Edited by bedowin on 08-24-2000 at 01:25 PM]
Pass Variable To Pop Up Window !
i want to pass a variable on the URL to a pop up window, i write down the code below but it does not work, i don't know if what i'm doing true ?
Pass A Variable Into A DECommand
Is is possible to build a SQL DECommand and leave it open for a variable to be passed to it so that only a certain recordset is returned at runtime?
I have a DataReport at it is populated by this DECommand as it's DataSource and DataMembers, but I need it to return only one record that is determined at runtime by the user.
Or do I have to build all of the Report by setting the Dsource and Dmember by code? Ugh.
Can't Pass A Variable To A Module
Splash Sreen is on Form 1 along with a DriveListBox which is made invisible
Private Sub Form_Load()
Drive1_Change When Form1 Loads it should call Drive1 Change which In turn call s FindDir But it
Private Sub Drive1_Change()
ListCount = 0
Item$ = Drive1.List(ListCount)
'CurrentY = 600
'Form1.Print "This should work"
'ListCount = 0
'Item$ = Drive1.List(ListCount)
CurrentY = 500
CurrentY = 900
Form1.Print "This should work"
Pass Variable To Macro Sub Routine
Is there a way to pass a variable to a macro sub?
Basically, I have 5 rows of 7 checkboxes that each create/copy worksheets and/or delete worksheets. I would assign the same macro to them if I could pass the name of the checkbox with the sub call. Otherwise, I will have to write a sub routine for eash checkbox.
Is there a way to capture when a checkbox is changed? Other then assigning a macro?
I found this: http://www.dailydoseofexcel.com/arch...ough-onaction/
Excel 2007 gave me errors on the sytax. So I changed the code to the following:
Dim sCheckBox As String
sCheckBox = "chk_log1"
Sheets("Setup").CheckBoxes(sCheckBox).OnAction = "'" & "Setup_Checkboxs_onclick" & "(" & sCheckBox & ")" & "'"
Which does not work. It does call the sub routine but the variable is null.
Pass Variable To 2nd Instance Of Excel
Is it possible to pass a variable (such as the users screen resolution) from one instance of Excel to another.
For example, in the app which I am creating, the first instance of Excel captures the users 'current' screen resolution settings, afterwhich it then physically changes this to an optimum setting for my app. Then (before closing itself down) the first instance of excel creates a second instance of Excel and loads the main user interface into this second instance.
All of this works fine however, I would like the first instance of Excel to pass the previous (what was 'current') screen resolution settings to the second instance of Excel. The second instance of Excel can then reset the screen resolution to the original settings before closing itself down.
Hope this make sense.
Any help would be greatly appreciated.
Pass Multiple Variable In Function
I was wondering. How can I can multiple arguments to function. I know how to pass one :
Public Function Test (Var1 as string)
But suppose I want to pass three values.
Any ideas ?
Pass Variable From Command Line
Can someone tell me, in short, how do I access the variable passed from the command line when executing my application?
I want to use the variable in my program. For example:
myprg.exe %1ormyprg.exe "mystring"What should i search for when looking up a reference on this?
Thanks in advance for any help.
(vb6 or .net)
Pass Variable To Crystal Reports 9 From Vb6.0
I apologize if this is on the board somewhere...but trust me, I've looked
Background info: VB6.0 Crystal 9.0 SQL Server database w/ ADO connection. I am connected and can view the reports I need.
I am trying to pass parameters when I run my report so that it will not prompt the user. I know the parameter names (BeginDate, EndDate) and have stored them in an array (arrParam). I also know what values I would like to pass (11/01/03, 11/20/03) these values will also be in an array (arrParamValue)
The reason the parameters are in an array is because they are pulled off of a database and are delimted by a comma and I simply split them and stored each value in an array.
1. Can I set the value of a dataset equal to the array values? (so that i could use Report.Database.SetDataSource newDataSet
2. If not is there another way to simply pass the string values as parameters to the report?
Pass Object Property As Variable?
Lets say I have a combobox named "cbo"
I want to get the "count" property so I do :
and it shows me 10.
But I want to make the property a variable like this:
sProp = "count"
msgbox cbo & "." & sProp
How do I do that so it works, as the above doesn't actually work the way I want it.
Pass Variable's Values Among Procedures
My main sub is a control event (cmdOk_Click()) procedure. As I Know, you cannot put arguments to that kind of subs, am I right? But I need to pass the value of a variable that is calculated to another procedure. So I don't know how I can pass its value to the cmdOK_Click sub. Have you any idea??