Assign Value To Variable On Other Form

Aug 16, 2013

I have set a "form-wide" variable on a certain form to contain integers. I want to populate this variable from a subform located on this form.

So, for example, if the form has an integer for CompanyID, I want to populate this variable from the subform so that when I am back on the main form I can use this variable with the populated variable. What is the syntax for this?

View Replies


ADVERTISEMENT

Assign Variable From SQL

Dec 28, 2005

I have a table set up like this:

tbl_original
account, invoice
11111, 1
22222, 1
33333, 5
44444, 3

I want to create a function module or something similar which will assign a variable to the max invoice # used on that table, using sql if possible. I tried something like this, but it's not working.

Public Function max()

Dim maxinvoice As String

maxinvoice = "SELECT Max(tbl_original.invoice) AS MaxOfinvoice" & _
"FROM tbl_original;"

MsgBox maxinvoice

End Function

I would like the msgbox to popup saying "5", since that is the max invoice # used based on the above table.

I don't have too much experience using modules on their own without forms and variables on the form to assign to, can someone make a suggestion?

Thanks in advance!

Vassago

View 14 Replies View Related

Cannot Assign A Variable

Nov 7, 2007

I have a simple combo box with two options - elective and emergency. They are set up on a continuous form.
When i try to choose a value it comes up with the message "You cannot assign a value to this object". I have checked the three criteria it mentions, object being on a form open in design view (no), value too large for field (no - text field with (defaulted) size of 50), control on a read -only form (no, form is editable).
The strange thing is as soon as you clear the error message box it lets you enter the value anyway.
Any ideas?

View 2 Replies View Related

Assign Data From Table To A Variable

Aug 28, 2004

Hy,i have this problem:
I've got a table that has column called car_id which is primary key and autonumber.
How can i get last record from that column and assign it to variable which i defined as integer.
Is there something like:
myvariable=max("car_id","mytable") ????
Thankls for any help

View 2 Replies View Related

Forms :: How To Assign Variable Shipping Rates

Jan 21, 2014

I am using a basic Order form and Order Details subform to capture my information. Customer is selected, then Products and Quantities are filled in... the subform calculates the total price. This all works great. Then I have a problem.

I have some national customers that require shipping to multi regions. I would need to select the regions and it has to calculate a new case cost for each product for each area. Could be up to 100 (10 products x 10 areas) new calculated prices.

Then for other customers, I will use just the case cost for the whole order (multiple products) and add one shipping fee to cover the drop. 3 products and only 1 fee added to the total.

Currently, my Order Form uses a Tab page and the Order Details are on the first tab. I could put the Shipping Info on the second tab, I just don't know how to add up to 10 different shipping regions to generate 10 new prices or the one drop fee to the total price.

View 1 Replies View Related

You Tried To Assign The Null Value To A Variable That Is Not A Variant Data Type. (Er

Jul 1, 2007

Hi,

I am getting this error 'You tried to assign the Null value to a variable that is not a Variant data type. (Error 3162)' I know why I am getting the error, I found out that Form and Subform should be implemented only with one-to-many relationships where the Subform is the many end. However, I have the opposite of that for a reason.

Is this bad practice? Is there anyway around it or to fix the error please?

Any help will be very much appreciated,
B

View 14 Replies View Related

Modules & VBA :: Declare Public Variable And Assign A Default Value

Nov 7, 2013

I want to define a public variable and i am using the following code but it gives me Compile error Invalid outside procedure.

Code:
option explicit
public ABC1 AS VARIABLE
ABC1="FALSE"

View 7 Replies View Related

Assign Autonumber & Form Copy

Feb 8, 2006

I don't know if this is possible or not. I know you can assign your own autonumber by working w/ an append query. But my question is, if I have a number that is 1.0 - can I change the 10th spot after the decimal? I tried it myself w/ the append query but it changes the 1 to a 2.0. Is there a way to do that?

My next question is - I know there is a copyobject. I want to be able to click on a button, & it copies a form. BUT, you have to enter either a destination for the form or a new name for the form. But the problem is, I want to keep the current destination and the form name will change each time there is a new form created. Is there a way to have something pop up for me to rename the form?

Thanks in advanced.

View 3 Replies View Related

Forms :: Linked Table - How To Assign Image To A Control In A Form

Dec 7, 2014

I have a linked table in ms access and it has a column as details. in ms access when i click on this button i will go to another form. i want to assign a picture (for opening a form) to this column but i don't know how i have to do this. my form opens as a datasheet view.

View 3 Replies View Related

Forms :: Assign A Query To The Record-source Of A Form Dynamically?

Apr 27, 2013

Is it possible to assign a query to the recordsource of a form dynamically? I assume the answer is yes. Can this action be done when the form is not open? If yes what is the correct syntax to use when the code is in a normal module as a public sub? I tried many possibilities and could not get it to work.

Code:
Dim ForNm as string
Dim Qry as string
ForNm = "PersonalFm"
Forms(ForNm).Recordsource = Qry
Forms![PersonalFm].Recordsource = Qry
[Forms]![PersonalFm].Form.Recordsource = Qry

View 14 Replies View Related

How To Randomly Assign A Person Based On Entered Field In Form

Feb 10, 2015

I need to assign those appraisers to an order based on what county they cover. My main table (orders) is simple. Just an order number, order date, county and appraiser.I have a form with entry fields for all these except appraiser. I envision a "assign" button that will then pick the next appraiser in the county that was chosen. It's just a "round robin" type of thing, so the first order placed for Monroe would be assigned to ABC. The next order would be for Cecil and would assign 123. Next order for Monroe would assign DEF. I know there are many way this can be done but I've been looking at this for hours and I'm drawing a blank on the easiest way to do it.

View 5 Replies View Related

Forms :: Login System That Assign Security Clearance - Form Not Found Error

Jun 24, 2013

I am relatively new to Access and VB. I am trying to create a log-in system that assigns a security clearance to each user and then restricts access to certain forms and reports based on security clearance. Right now, I have set up the log-in system - that seems to work fine. But when I try to lock the form based on security clearance, I get the 2450 - Form Not Found - error.

The code I am using on the form is as follows:

Private Sub Form_Open (Cancel As Integer)

If Forms!frmLogin!cboUser.Column(4) <> 1 Then
MsgBox "You do not have access to this form", vbOkOnly
DoCmd.Close acForm, "formname"
EndIf

End Sub

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

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

Reports :: Object Variable Or With Block Variable Not Set

Apr 15, 2015

Runtime error '91'

Running Access 2010.

I have two reports running off of the same crosstab query. I copied one report to make the second report, then modified the second report to change the background of column fields satisfying certain conditions. These lines of code were added to the Detail_Format section, in color below. The report with the extra code lines does not error--the original report errors.

Code:
Option Compare Database
' Constant for maximum number of columns EmployeeSales query would
' create plus 1 for a Totals column. Here, you have 9 employees.
Const conTotalColumns = 11

[Code] .....

If I say OK (rather than debug) after the error message, I can then click the button for the report again and it runs without complaint. And, as I said, the report with the added code never errors.

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

What Is A Form Level Variable?

Aug 24, 2006

When you are given the instruction (for code) which says "Create a form level variable" - what does this mean?

View 3 Replies View Related

Forms :: Using Variable For Form Name?

Feb 21, 2014

Is there a way to use a variable instead of a form name?

e.g. FRM1 is a form

Forms![FRM1]!textbox1.SetFocus

Instead of FRM1 , a variable is used which can be any other form name.??????

View 10 Replies View Related

Object Variable Or With Block Variable Not Set

Apr 23, 2006

I have a networked database. It is accessed with computers that have both Office 2002, and office 2003. I get the following error message on computers with Office 2003:

"Object variable or With block variable not set"

It happens occasionally and the problem generally fixes itself so I dont think there is anything wrong with my coding.

And when it happens on the computers with office 2003 the ones with office 2002 can open the database fine.

What can be causing this?

Thank you in advance

View 1 Replies View Related

Object Variable Or With Block Variable Not Set

Dec 14, 2006

Good afternoon all,

The following block of code was working great until I came into work this morning. This routine is called from the OnClick event of several combo boxes. When it does, I recieve the error listed above (Object variable or With block variable not set) on line:

If Me.cbxAss_Filter <> "All" Then

Any ideas? I'm running on no sleep in the last 24 hours so I'm sure I'm missing something simple

The code itself checks the contents of a form and builds a string of conditions which I apply to the Form's filter property to filter records.


Code:Public Sub CreateFilter() '************************************************* **** 'Name: CreateFilter 'Purpose: Generate a string to filter the form 'Inputs: None 'Outputs: None 'Instigates: Me.Filter ' 'Updated: 11/30/06 'By: Chris Lounsbury '************************************************* **** 'Vars Dim strFilter Dim lngLength As Long strFilter = Null strFilter = "" 'Each filter box has its own check for contents If Me.cbxAss_Filter <> "All" Then strFilter = "assigned = '" & Me.cbxAss_Filter & "' AND " End If If Me.cbxAction_filter <> "All" Then strFilter = strFilter & "action = '" & Me.cbxAction_filter & "' AND " End If If Me.cbxStatus_filter <> "All" Then strFilter = strFilter & "status_rsrch = '" & Me.cbxStatus_filter & "' AND " End If If Me.Combo34 <> "All" Then strFilter = strFilter & "rims_flags = '" & Me.Combo34 & "' AND " End If If Me.cbxAAMB_filter <> "All" Then strFilter = strFilter & "aamb = '" & Me.cbxAAMB_filter & "' AND " End If 'Check if filter string was built If strFilter = "" Then Me.FilterOn = False Else 'Determine length of Filter String 'minus the trailing ' AND' lngLength = Len(strFilter) - 5 'Chop off ending ' AND' and set the form filter If lngLength <= 0 Then Else Me.Filter = Left(strFilter, lngLength) Me.FilterOn = True End If End If 'debug 'MsgBox (strFilter) End Sub

View 1 Replies View Related

Form Variable Passed To Query

May 7, 2007

Not sure if I am asking the right question, but....

I would like to pass a string variable to a query but it does not seem to work.

In the query, my criteria for the date field is (and works):

>=[forms]![frmDisposition]![FromDate] And <=[forms]![frmDisposition]![ToDate]

But, this is not working for the ID field criteria:

[forms]![frmDisposition]![ID]

In the forms code, I have a string based on the result of 3 check box. I tried using an unbound (ID) control to display the string so I know that the value of the string is correct. EX: "FW" Or "MA" Or "PD"

Is it possible to pass the value of the string to the query or do I need to try and pass the value of the unbound control to the query?

View 6 Replies View Related

Insert Form Variable Into Table

Apr 7, 2005

Hi
I have a form that displays line items and their cost. At the bottom of the form I have a text field called text17 that uses a sum to total the value of all the line item costs with this : =Sum([Line Cost])

How would I pass that value into a database table?

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







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