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 Replies


ADVERTISEMENT

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

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 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 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

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

Modules & VBA :: Set A Public Variable In Another Database To True

Apr 14, 2015

Is it possible to open another database, set a Public boolean variable in a module?

in db1: Open database by Access.Application, OpenCurrentDatabase, setting obj to db2.CurrentProject, loop through main objects

in db2: Public ByPassCloseVar As Boolean is in a module ModLinkTblReview

I have a process that opens up a database runs through all of its objects to get their properties and values. There is a form that is set up on Unload to close the tool if the variable is set to False. When I open the form to get the properties and their values, then close the form, it closes the database. I would like to set the variable to true in order for the database to stay open.

Thought something like this would work: db2.Modules!ModLinkTblReview.ByPassCloseVar = True

Indicates that method or data member does not exist.

View 5 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

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

Modules & VBA :: Open One Database Form Another And Pass Variable To It

Feb 19, 2014

I have a button on my main db, that opens a second db using hte following code:

----------------------
'Dealing with external objects, use inline error trapping
On Error Resume Next
Dim appAccess As Object

Dim db As Database
Dim strAppPathName As String
Dim strAppName As String
Dim strTimesheetPathName As String

[Code] ....

This code works great to open the other db, and handles wheter the other db is already open or not, but I cant seem to pass the variable to the other db using the startup switch /cmd.

I suspect if I used the shell method it would pass the cmd , but I havnt found any way to test if the db is already open with the shell method.

How can I pass a variable to the other db when opening it using VBA?

View 10 Replies View Related

Modules & VBA :: Open Another Database And Send Variable Back

Apr 24, 2015

I have code that from DB1 opens DB2 and runs a Function in DB2.

The DB2 function produces a Boolean result that i am trying to get back to DB1 without success. Below is the script.

Sub Test22()
Dim AC As Object
Set AC = CreateObject("Access.Application")
rc = "K:ARSHRAutomation_ProjectsMikeFEDB2.accd b"
AC.OpenCurrentDatabase (rc)
AC.Visible = True
AC.Run "SendVariable"
End Sub

Because i am using AC.Run "SendVariable" i cant find a way to get the value of SendVariable!!

View 2 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 91 - Object Variable Or With Block Variable Not Set

Jul 8, 2013

Error 91 - Object variable or With block variable not set

I am getting this error telling me that an object variable is not set.

I know which variable it is but when I step through the debugger it sets the variable and all is fine? Issue is that public variable of a class is not getting set when the VBA Editor is not open?

View 14 Replies View Related

Modules & VBA :: Sorting / Object Variable Or With Block Variable Not Set

Oct 3, 2014

This code runs fine the FIRST time, however trows up a message the SECOND time it is run.

The error is on the line ".Range"

I am trying to sort records which have been exported to Excel.

Dim LR As Integer
LR = 5
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set wbRef = xlApp.Workbooks.Add
With wbRef

wbRef.Activate
.Worksheets("Sheet1").Activate
With ActiveSheet
.Range("A2", .Cells(LR, "O").End(xlUp)).Sort Key1:=.Range("C2"), Order1:=xlAscending, Header:=xlYes
End With
end With

View 3 Replies View Related

Modules & VBA :: Update Contents Of Variable But Not The Variable Itself?

Aug 20, 2014

I look at a lot of files to see when they were last updated. I wanted to write a generic procedure to manage that so ..

Code:
Public fDate As Variant
Public vField As String
Public vFile As String

'GTSdata
vField = "txt_gts_data"

[Code] ....

What I hoped Me.vField would do is update the date field [txt_gts_data] on my form with the date the file was last saved.

i.e. me. txt_gts_data = fDate

What actually happens is the variable vfield gets updated from "txt_gts_data" to 19/08/2014 then later code falls over because the fieldname is lost .

Me.[vField] corrects itself to me.vField (and does not work)
Me!vfield falls over (cannot find the field vField, not surprising J)

How do I say update the contents of the variable, not the variable itself?

View 7 Replies View Related

Modules & VBA :: Passing Image To Another App?

Dec 27, 2013

I want to use an On Click event on an image field on a subform to fire up either Windows Photo Viewer or Corel PaintShop Pro with that image active - but don't really know where to start. DoCmd, Shell ?

View 5 Replies View Related

Modules & VBA :: Passing Information From One Form To Another

Sep 25, 2014

I have created Form1 with a button and after I click the button Form2 appears (frm_Rollover_Progress). Form2 is a (poor mans) progress indicator that makes some labels visible after a section of a query has run. I have set the first label on the form to Me.lblProgress1.Visible = True but I keep coming up with Compile Error - Method or data member not found. However, when I put a button on the second form and copy in the exact same code then Me.Label1.Visible = True works. I have tried to SetFocus to an item on Form2 but still does not work.

'Open progress form to show progress indicator
DoCmd.OpenForm "frm_Rollover_Progress", acNormal, , , acFormReadOnly

'Add current changes to Total Changes table

Me.lblProgress1.Visible = True
Me.Label1.Caption = "10%"
DoCmd.OpenQuery "qry_Change_AddedQX2", acViewNormal, acAdd
Me.lblProgress2.Visible = True
Me.lblProgress3.Visible = True
Me.Label1.Caption = "30%"

View 2 Replies View Related

Modules & VBA :: Passing Variables To A Sub Routine

Jan 13, 2014

I have a public sub routine which requires parameters to be passed to it when I call it from an access form. When I try to enter the code to call the sub I get a compile error. I've also tried calling it from another sub in the same module but get the same compile error - see below.

Code:
Sub EmailData(Datafile As String, To_mail As String, CC_mail As String, Subject_mail As String)
'code to use variables passed in
End Sub

[Code]....

View 4 Replies View Related

Modules & VBA :: Passing TempVar Value Into A Table

Dec 13, 2013

I have a form in which the user selects a combobox and this value becomes a tempvar called "un" on clicking a command button I need the value of "un" to be passed into a table."un" is a number.Here is what I have so far.....

Code:

CurrentDb.Execute "INSERT INTO timedata(startedby) " & _
" VALUES(" & TempVars!un & ")"

but seem to get syntax errors all the time.

View 6 Replies View Related

Modules & VBA :: Passing New Data From One Form To Another

Jan 19, 2015

I have a form called frmSchedule. Within this form, I have a combo box called cmbCD. I have code in the cmbCD NotInList Event. If the user inputs a number not in the list, the folowing code opens up a new form (frmPatients). The user can now add a new record to the database.

Code:
Private Sub cmbCD_NotInList(NewData As String, Response As Integer)
Dim Result
Dim Msg As String
Dim CR As String

CR = Chr$(13)

[Code] ....

I got this code and it works. However, when the user inputs a new number in frmSchedule, the NotInList event takes them to frmPatients. The users then have to re-type the number in frmPatients.

My question is: Is there a way I can trasfer the NewData from frmSchedule into frmPatients, so the users don't have to re-type the number?

View 2 Replies View Related

Modules & VBA :: Passing RecordSet As A Parameter

Sep 19, 2014

I'm trying to the following sub to automate the creation of RecordSets but I'm confuse how to get it done properly.

Public Sub OpenRecordSet(SQLString As String, NameRecordset As Object)
Set NameRecordset = New ADODB.Recordset
NameRecordset.Open SQLString, adOpenStatic, adLockOptimistic

I want to pass the name of the recordset as a parameter but I don't know how to set it.

View 1 Replies View Related

Modules & VBA :: Passing Combo Box Control To Procedure

Nov 21, 2013

On my form I have a combo box where the user can select the sex of a person. I had set the row source of the combo to a table, tblSex and this works fine. Now I want to programatically add the table entries ( simply male or female) to the row source, having set the combobox to value list. I cant see how to pass the combobox and tablename parameters and I am getting an error on form load "The expression you entered as the event property setting produced the following error: UserDefined type not defined" The calling procedure from frmPeople is

Code:
'---------------------------------------------------------------------------------------
' Procedure : Form_Load
' Author : Administrator
' Date : 21/11/2013

[Code].....

I think the way the parameters combobox and tablename are passed is incorrect. I want to write a robust procedure which I can use for each of the comboboxes on my form.

View 7 Replies View Related







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