473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Problem setting a Form variable

Hello. I am trying to set an object variable to a 'datasheet form' that I have so that I can manipulate the column widths programmically. I am doing it in exactly the same way that I am doing it for another 'datasheet form'. With one, it works perfectly, with the other, I cannot set the variable. I get an "Object Required" error. But there does not seem to be any differences in the forms, and the code is exactly the same. Here is the code (that causes the error):
Expand|Select|Wrap|Line Numbers
  1. Private Sub Child274_Enter()
  2. Dim frm As Form
  3. Set frm = Form_frmtblObsoleteParts
  4.  
  5. MsgBox frm.chrObsoletePN.ColumnWidth
  6. MsgBox frm.chrPartRevision.ColumnWidth
  7. MsgBox frm.chrMakeBuy.ColumnWidth
  8. MsgBox frm.chrQtyOnHand.ColumnWidth
  9. MsgBox frm.chrQtyOnOrder.ColumnWidth
  10. MsgBox frm.chrCostPart.ColumnWidth
  11. MsgBox frm.chrTotalPrice.ColumnWidth
  12.  
  13. End Sub
Feb 28 '14 #1

✓ answered by NeoPa

You've already found the first point I was going to make. The properies of the form include one called .HasModule (Near the bottom of the list). Set this to Yes if you want a module to be associated with it (Obviously your approach works too).

When referring to an open form it is more common (and more precise) to do so via the Forms() collection :
Expand|Select|Wrap|Line Numbers
  1. Forms("frmtblObsoleteParts")
or :
Expand|Select|Wrap|Line Numbers
  1. Forms!frmtblObsoleteParts
Form_frmtblObsoleteParts is, technically, a reference to the class rather than the instance.

Referring to Items on a Sub-Form gives further details.

5 1307
NeoPa
32,556 Expert Mod 16PB
Where is the error message and what line does it occur on?
Mar 1 '14 #2
It is:
Run-time error '424'
Object Required

Occurs on line 3 of the code when I try to set the variable. It is acting as if the form does not exist. But it does.

Thanks,
Mike
Mar 4 '14 #3
It is working now. I looked at the VBA project, and there was no object for it there. So I created an open event and deleted it just so that there would be an object for the form in the VBA project. Now it is working fine.
Mar 4 '14 #4
NeoPa
32,556 Expert Mod 16PB
You've already found the first point I was going to make. The properies of the form include one called .HasModule (Near the bottom of the list). Set this to Yes if you want a module to be associated with it (Obviously your approach works too).

When referring to an open form it is more common (and more precise) to do so via the Forms() collection :
Expand|Select|Wrap|Line Numbers
  1. Forms("frmtblObsoleteParts")
or :
Expand|Select|Wrap|Line Numbers
  1. Forms!frmtblObsoleteParts
Form_frmtblObsoleteParts is, technically, a reference to the class rather than the instance.

Referring to Items on a Sub-Form gives further details.
Mar 4 '14 #5
Very useful... Thank you very much.
Mar 4 '14 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Aamer Nazir | last post by:
Hi, I am having problems setting the value of a variable in a SQL String that I have to create dynamically in my procedure. The code that I currently have is as follows: set...
7
by: rickcheney | last post by:
I just changed my Access 2002 database to a SQL Server ADP project. I had a form where the user entered a value into a text box and when a command button on the form was clicked a Report was...
10
by: yawnmoth | last post by:
i've written some javascript code that i believe should set a form variable to a certain value, depending on what the user clicks on. unfortunately, it isn't working. here's the url: ...
2
by: Mikkel Faarup | last post by:
Hi All I am are experiencing difficulties setting Windows.Form heights above around 1000px on screens with the resolution set to 1024x768. The form is simply cut off and a scrollbar is set. The...
2
by: Chuck W. | last post by:
Hi there, I'm working a query that processes form variables. However one of the variables begins with a number. This is from a canned program so I actually need to remain, eg: <input...
1
by: clickon | last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains a text box, TextBox1 and TextBox2 respectively. If i put the following code in the respective activate event handlers for...
8
by: tnspc | last post by:
I'm trying to access a Request.Form variable and plug it into an SQL statement, so that the statement will select just the particular data I need. Here's the offending snippet of code: sql =...
3
by: igurov | last post by:
Hi all, I have the following simple cmd. script: @ECHO OFF copy "C:\Program Files\Microsoft Visual Studio 8\VC#\CSharpProjects\date_string\date_string\bin\Release\date_string.exe" c:\temp set...
4
by: KEV999 | last post by:
Would like any suggestions please on how to achieve this - I'm using MS Access 2003. At present for a simple data entry situation using a form, the user entering the data enters their intials into...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.