Passing A Variable From One Form To Another

Mar 5, 2008

how can i pass a variable from one form to another

this works fine
Tracking_Number = Forms("Main").Control("mytext")

but if "mytext" was in vb (rather than from a text box as shown above) how can i do this

View Replies


ADVERTISEMENT

Passing Variable Between Form And Report

Jul 13, 2005

Hi

I have a matrix variable (ex: test(7,3)) define as private in a form's code vba. In this form, I open a report in which I would like to show the values of my matrix variable. How can I do this efficienly ... what i use now is a public buffer variable in a module(it eats memory for nothing)

can someone tell me a trick ...

tanks a lot

View 1 Replies View Related

Passing Variable - Form Must Be Open?

Sep 21, 2005

I'm attempting to pass a variable from form to form...I'm having trouble doing it...I checked the forum and read a little that the form I'm passing it from must stay open...is this correct? I have my variable as: Public strUserName as String. It does work fine if I leave the form open then I can pass it...

But I want to be able to close the form and still pass the variable...How can this be acheived?

Thanks in advance.
Kacy

View 3 Replies View Related

Passing A Date Variable To Anaother Form

Aug 5, 2006

In form1 I've a command button to open form2.

Code in form1:

Private Sub button_Click()
On Error GoTo Err_button_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form2"
stLinkCriteria = button.Caption
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_button_Click:
Exit Sub

Err_button_Click:
MsgBox Err.Description
Resume Exit_button_Click

End Sub

button.Caption contains a valid date value

In form2 I want to display the date in a label.

Code in form2:
Private Sub Form_Load()
Dim DatePassed As Date

DatePassed = CDate(Me.OpenArgs)
label.Caption = DatePassed
End Sub

On executing I get an error like "Invalid use of null value."

Who helps?

View 5 Replies View Related

Passing A Variable's Value Into An SQL Statement

Feb 6, 2006

I want to build an SQL statement in code which includes the value stored in a string variable where the variable name includes a loop counter.

This is a much simplified example of what I am trying to do:

Dim i as integer
dim Strtable1 as string
dim Strtable2 as string
dim Sqlstring as string
...

Strtable1 = "tblEmployees"
Strtable2 = "tblSales"
...
Sqlstring = " select * from ... where....."

for i = 1 to 10

DoCmd.RunSQL "INSERT INTO " & StrTable & i & sqlstring

Next i

I am not sure how to get the table names stored in the string variables into the SQL statement. When I try the above it looks for a variable named StrTable, not StrTable1, StrTable2 etc.

View 4 Replies View Related

Passing Variable Between Forms

Aug 8, 2006

Hi Everyone,

I'm trying to pass a variable called MyFilter between forms but am having problems. I have created a Module and declared MyFilter as a public string.

The original code in my first form is:

Private Sub Command65_Click()
Dim MyFilter As String
If Me.Filter = "" Then
MsgBox "Please apply a filter to the form first."
ElseIf Me.Dirty Then
' Make sure the record is saved
RunCommand acCmdSaveRecord
Else
MyFilter = Me.Filter
DoCmd.OpenReport "Temp", acViewPreview, , MyFilter

End If
End Sub

How to I change this so that it now stores the value in the Public variable instead of the Private one which it is doing above?

Thanks,

View 5 Replies View Related

Passing A Variable Between Two Sub Routines

Sep 13, 2004

I have an event on a form kicked off by On Delete and I have an event on the same Form kicked off by After Delete Confirm. I need to pass a variable from the On Delete Event to the After Delete Confirm Event. I have set up the variable as public, but it keeps getting reset inbetween the two events. Any ideas?

View 1 Replies View Related

Problems Passing Variable From Combobox

Apr 29, 2007

Hi all!

I have a college project were we have had to code a database for a fictional hospital to hold patient, doctor, consultant and appointment information. I am struggling with one particular problem.

I am trying to pass a variable from a combobox of results to another form to display a certain record.

I am trying to send:

stLinkCriteria = "[NHS_Number]=" & "'" & Me![lstSearch].Value & "'" & " AND [AppointmentID]=" & "'" & AppointmentID & "'"

to the form but it fails, yet if I "hard code" the variable it works:

stLinkCriteria = "[NHS_Number]=" & "'" & Me![lstSearch].Value & "'" & " AND [AppointmentID]=23"

Can anybody shed any light upon this please?

View 2 Replies View Related

Modules & VBA :: Passing Variable From One Database To Another

Jan 6, 2015

I need to pass a variable from one Access Database to another

The scenario is I have a item number in one database that I need to use to open a form in another database,

I can open the database using vba, currently launching a BAT file that copies the latest version database to a local drive and then opens it,

Is there an easy way to pass the variable after this has completed?

View 1 Replies View Related

Reports :: Passing A Variable To A Report Textbox

Sep 16, 2014

I have a form with 5 buttons on it. Each button is meant to select a warehouse location, so a query can be run to give an inventory report for that location. There is a separate query for each button and the OnClick event does properly modify the recordsource to give the appropriate data to the report for the location selected.

To this functionality I want the OnClick event VBA to pass the warehouse location to a textbox on the report, so the title of the report reflects that inventory location.

My code thus far is:

Private Sub Command5_Click()
Dim mySQL As String
Dim WHSE As String
mySQL = "SELECT [Master Part List].[Part Number], [Master Part List].Category, [Master Part List].Description, [Master Part List].MaterialCost, [Master Part List].Inventory, [Master Part List].Update, [MaterialCost]*[Inventory] AS [Total Cost], [Master Part List].Warehouse"

[Code] ....

When I get the report, the textbox is empty, instead of containing the text value for the warehouse location.

View 5 Replies View Related

Reports :: Passing Variable To Report Record Source?

May 7, 2013

I have a subroutine that successfully builds a SQL statement "strSQL", which is a public variable.

Using msgbox, I can read that the value is correct -
SELECT * from tblIncidents WHERE [Nature] = 'Hover';

(The select statement may be complex, e.g. [Nature] = 'hover' AND [COLOUR]= 'Blue' AND [GRADE] = 'High')

I want to pass the variable strSql to my report rptIncident in the following command:

Private Sub CmdPrintReport_Click()
If Right(strsql, 1) <> "'" Then 'check if statement was built
Else
strsql = strsql & ";" 'add trailing ; to statement
MsgBox strsql
DoCmd.OpenReport "tblincidents", acViewNormal, , strsql
End If
End Sub

I get a flashing error, then runtime error 3075 - |1 in query expression '|2'.

View 6 Replies View Related

Modules & VBA :: Error Passing Variable To Class Module

Jan 30, 2014

I am trying to pass a boolean variable to a class module

Code:
Set rps.ViewS = View

the code in the module that this in theory is calling reads as

Code:

Private ViewC As Boolean

Public Property Set ViewS(ByRef ViewA As Boolean)
Set ViewC = ViewA
End Property
Public Property Get ViewS() As Boolean
Set ViewS = ViewC
End Property

However I am getting the error message

Quote:Definitions of property procedures for the same property are inconsistent, or property procedure has an optional parameter, a ParamArray, or an invalid Set final parameter.

View 6 Replies View Related

Modules & VBA :: Passing Variable From Excel To Fire Access Query

Dec 17, 2014

I'm running a VBA routine in Excel that loops through a lot of data. As part of the process, I'd like to pass a variable from Excel to an Access database that is open and have it run a query based on that value.

View 4 Replies View Related

Modules & VBA :: Passing Values Of Selected Items From First Form Until Third Form

Aug 12, 2013

I would like passing values from first form until third form.

In the first form I have a list box after selecting items (For each selected item in first form I have 4 values) and pressing button (or right click of mouse) the second form will be open, then in the second form I have 2 option (inserting, deleting), when I select inserting or deleting in the second form, third form will be open, in the third form there is a "OK" button, when I press that, passed values from first form will be used for inserting or deleting records to the table.

View 4 Replies View Related

Passing Data From Child Form, To The Original Form

Dec 8, 2007

Hi All,

I'm not sure if this should go in here or in VB Programming, because it's to do with an Access Database but it's VBA code.
But I understand that VBA and VB are different in the way they work.

I think this may have been looked at before, but I'm not very good at using the search function. I've looked on google, but all I've seen doesn't seem to be for my use, so I came here as recommended by "RadioActive Frog" who I believe is a member here.


Right, basically, I am writing an Access database for my company's ordering system.

I have a form called "Enquiry" which has many tabs, one of these is the "client" tab in in here are many fields:

Firstname
Surname
Company
Addressline1
Addressline2
Town
County
Postcode
Phones
Fax
AltMobile
Email
ContactType

Now, there is an option to enter a new client or search the database for an existing client and it is basically the "new client" which I'm having issue with at the moment.

Basically, clicking the button "New Client" opens another form called "Client". Here, the user enters the data into fields which are the same as above (but on this contact form).

When done, they click a button called "Save and Close" which then asks the user if they want to paste their entered data into the original main "Enquiry" form.

It's this last bit, the transferring of this data I can't get my head around and would be incredibly greatful for help with.

My Code is below:

Code:Private Sub Save_Click()On Error GoTo Err_Save_Click ' On clicking save, a dialogue box will open asking if you want to paste this data ' into the enquiry form. Clicking yes will do this. Clicking no will just close the box 'declare intpress as an integer Dim SavePress As Integer 'Save Command DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 'when save and paste is clicked, ask if the information should be pasted into the form or not SavePress = MsgBox("Would you like to paste this Contact Information into the Enquiry Form?", vbQuestion + vbYesNo, "Paste details") If SavePress = 6 Then 'If the enquiry form was the form which initiated the cotact form, then copy and paste 'the informtion into the enquiry form and the close the form 'If "Enquiry" = Me.OpenArgs Then <------ I have decided not to use this, as it doesn't seem to work. (I'm probably not using it correctly) Enquiry!FIRSTNAME = Me.FIRSTNAME Enquiry!SURNAME = Me.SURNAME Enquiry!COMPANY = Me.COMPANY Enquiry!CATEGORY = Me.CATEGORY Enquiry!ADDRESSLINE1 = Me.ADDRESSLINE1 Enquiry!ADDRESSLINE2 = Me.ADDRESSLINE2 Enquiry!TOWN = Me.TOWN Enquiry!COUNTY = Me.COUNTY Enquiry!POSTCODE = Me.POSTCODE Enquiry!PHONES = Me.PHONES Enquiry!ALTMOBILE = Me.ALTMOBILE Enquiry!EMAIL = Me.EMAIL DoCmd.Close acForm, "Contact" Else DoCmd.Close acForm, "Contact" End If Exit_Save_Click: Exit Sub

But It's not working. It's giving an error saying "Compile Error: Variable not defined" and it highlights the word which I've mad RED in the code above. Now, I tried changing the exclamation for a fullstop, and I also tried writing "Form.Enquiry.FIRSTNAME" (and also with exclamation marks). None have given a working result.


I'll try and get some print screens too for more visibleness (new made-up word there) so you can see what I mean.


Blessings,
Si


Edit: here are a couple of print screens:

1. The Client tab/page of the main enquiry form:

http://i6.photobucket.com/albums/y218/Mr_Si/Enquiry.jpg


2. The Client Details form, which opens as a result of pressing the "New Client" button in the main enquiry form (shown in the background):

http://i6.photobucket.com/albums/y218/Mr_Si/Client.jpg


Argh! I forgot I couldn't post links to URLs

View 1 Replies View Related

Forms :: Passing Values From One Form To A New Record In Another Form

Oct 25, 2013

Have one form that contains values AssociatedProject and AssociatedRelease that need to be passed onto another form that opens with a new record. Have tried different variations based on what I read here and couldn't get them to work.

Initial form - frm_ViewList contains the values that I need to pass on and has a "Add" button to bring up the new form that also creates a new record. The add button contains the following:

Dim stDocName As String
MyAssociatedProject = Me.AssociatedProject
MyAssociatedRelease = Me.AssociatedRelease
stDocName = "Frm:ManageQuestionsAnswersProc"
DoCmd.OpenForm stDocName, acNormal
DoCmd.GoToRecord , , acNewRec

Then in the second form Frm:ManageQuestionsAnswersProc the following code is contained in the Before Insert:

Me.AssociatedProject = MyAssociatedProject
Me.AssociatedRelease = MyAssociatedRelease

View 3 Replies View Related

Passing Value To A Sub Form

Feb 26, 2005

Hello,

I have a combo box on a main form and one on a subForm (DataSheet View)...

I want the value in the main_combo to populate the sub_combo for every record in the subform.

I think the code would look like this, but I cant get it to work?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub MAIN_DUNS_AfterUpdate(Cancel As Integer)

Me.CLIENT_DEAL.SUB_DUNS = Me.MAIN_DUNS.Value

End Sub

MAIN_DUNS= Combo on main form
SUB_DUNS= Combo on sub form
CLIENT_DEAL= Sub Form
DEAL_INFORMATION=Main Form
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Any Ideas on how to get this to work correctly??

View 1 Replies View Related

Passing Value From Form To Report

Jun 20, 2007

Hello,

I have made one form for report purpose. When I enter Start date and End date, I get report of the date range. What I am looking that I want to print the start date and end date in my report. How can I reference date text box in my report?

thanks

mithani

View 7 Replies View Related

Passing ID Number To Another Form

Feb 16, 2005

i have two forms. one is the main form and there i put button that opened another form.
when i open the second form i want to link the ID number from the main form to the second form so i wont have to insert the number each time i am opening it.

View 1 Replies View Related

Passing Parameters To A Form

Dec 22, 2006

Hi all,

I have a continuous form that is bound to a SQL Server view.

For each record in my form I have a button, which when pressed opens up a second form. The second form is bound to a stored procedure that takes a parameter. The parameter value that I want to pass to this second form is the value of one of the fields in the first form.

I did the following in the click event of the button on my first form:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "SecondForm"

stLinkCriteria = "[Field1]=" & "'" & Me![Field1] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

However, when I run this it keeps prompting me to specify the value of Field1 so this value is obviously not getting through. Do you have any idea why this might be happening?

Thanks in advance
Kabir

View 4 Replies View Related

Passing Data Onto Another Form

Apr 11, 2007

Hi,
i'm quite new to Access and I have a problem passing data from one form onto another.

I have a form that I use for quotations based on the table T Quotations on it I have:
QuotationID as my primary
RefCust referring to which customer
Date
and a few other fields

Now i'd like to add a button that when clicked will open my order form. In other words when a quote is confirmed I'd like to click on the quotation form to confirm it and create an order on the order form.
Order form will open with a orderID autogenerated BUT will return the same RefCust as on the Quotation form, the same date and will give the quotationID as Refquote onto the new form.

Ex: on form quotation I have
Cust: abc company
QuotationID: 123
Date: Feb 25 2007
Quote: $300

when i click on confirm

the Order form will open with:
OrderID: 002 (autogenerated)
RefQuoteID: 123
Date: Feb 25 2007 (even though today might be April 10)
RefQuote: $300

Please help me

View 1 Replies View Related

Passing Values From One Form To Another

Aug 22, 2007

I am trying and have been unsuccessful at passing a value in a textbox from one form to another.

I have a form (Form1) and I click a button and Form2 opens.

What I want is a couple values from textboxes in the Form1 to populate a couple textboxes on Form2 when Form2 opens.

I CANT FIGURE THIS OUT....

PLease help

View 5 Replies View Related

Forms :: Passing A Value To Pop Up Form

Jul 22, 2015

I have a form and in the subform for that I have a button that opens a pop up form. I want to pass the value [ACB ID] to an unbound text box in the popup form but I am having trouble. My code for the button in the subform is:

DoCmd.OpenForm "addPartNumberMod", acNormal, , "ACB = " & Me.[ACB ID], WindowMode:=acDialog

Currently when I press the button it asks me to enter the acb value instead of carrying it over. Also, when i do type in a number into the dialog, when the form opens, the text box is blank.

View 4 Replies View Related

Reports :: Subform Field Linker Error - Obj Variable Or With Block Variable Not Set

Apr 16, 2013

I am creating a 2 level report to confirm an order. Main report already created, runs successfully called as subform/subreport under "OrderDetails" form. Linked to master using Order.ID. There are two versions of the confirmation report that have different layouts for different program types.

The hangup comes when I try to add a "Class Dates" subreport. It lists dates of individual classes and Skip dates. I have created the subreport as "srClassDates". When I add it to the main report, it lists the records. However, when I try to link it to the Main report, an error message box appears with the "object variable or With block variable not set".

I have tried rebuilding both the main and subreports, rebuilt the query, have not found anything that changes the result.

Linker has been working successfully on other subforms. Report with groupings works fine, but I need data from 2 tables both linked to order.id.

View 2 Replies View Related

Passing Parameters From Form To Queries

Mar 23, 2006

Good Afternoon,

I am trying to create a form where a user will enter in a value into a text field. Afterwards, when the user clicks "Enter", a query will run and will LOOK FOR THE VALUE THAT WAS ENTERED INTO THE TEXT FIELD. i.e.
User enters their address into the field and clicks the enter button.
Afterwards, a query will run like
select * from customers where address = @address <== the value the user entered into the text field. This is where the mystery lies. How do you pass values?????

Thanks,
Nervous Jervous

View 6 Replies View Related

Passing Values To A Form (calendar)

Jan 9, 2008

Hi All,

Thanks to "Beginning Access97 VBA Programming" by R. Smith & D. Sussman, I was able to implement the use of a calendar form to allow a client to select a date, rather than keying one in. And here I thought I was done with the problem....Wrong !!! The calendar form only works if existing records already have a date(shortdate) associated with the record.

But when I try to create a new record, the date field is "null" and I can't figure out how to pass a date value to the calendar control even though it's receiving a null. I get this "type mismatch" error I've bumped into the part of the code that was supplied via the book where the "property set datecontrol (Byval ctldate as Control) is set, but I can't figure out
how to deal with this incoming "null" value from the newly created record.

Can anyone help? I'll check in later on tonight if anyone is needing part of the code as reference to what I'm trying to accomplish.

Thanks so much.......CementCarver

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved