Open form with arguments - invalid use of NUL:

In main form:
Private Sub btnOpen_Click()
  DoCmd.OpenForm "frmEmployee", acNormal, , , acFormAdd, acWindowNormal, 
"Alan"
End Sub

In second form:
Private Sub Form_Open(Cancel As Integer)
  Dim empName As String
  empName = Forms!frmEmployee.OpenArgs <-- runt time error
    If Len(empName ) > 0 Then
      MsgBox empName
    Else
      MsgBox "null"
  End If
End Sub

The runtime error was:
Invalid use of NULL 


0
Alan
5/24/2007 5:45:30 AM
access.forms 6864 articles. 2 followers. Follow

7 Replies
799 Views

Similar Articles

[PageSpeed] 39

"Alan T" <alanpltseNOSPAM@yahoo.com.au> wrote in message 
news:u8mI8acnHHA.1244@TK2MSFTNGP04.phx.gbl...

>  empName = Forms!frmEmployee.OpenArgs <-- runt time error

Try empName = Me.OpenArgs

Keith.
www.keithwilby.com 

0
Keith
5/24/2007 9:43:29 AM
Hi,

1) My original post has been wrapped. The "Alan" is on the same line in my 
OpenForm method.
2) I tried Me.OpenArgs but no luck, still get the same error.

"Keith Wilby" <here@there.com> wrote in message 
news:46555adb$1_1@glkas0286.greenlnk.net...
> "Alan T" <alanpltseNOSPAM@yahoo.com.au> wrote in message 
> news:u8mI8acnHHA.1244@TK2MSFTNGP04.phx.gbl...
>
>>  empName = Forms!frmEmployee.OpenArgs <-- runt time error
>
> Try empName = Me.OpenArgs
>
> Keith.
> www.keithwilby.com 


0
Alan
5/25/2007 1:56:48 AM
"Alan T" <alanpltseNOSPAM@yahoo.com.au> wrote in message 
news:eofA0$mnHHA.588@TK2MSFTNGP06.phx.gbl...
> Hi,
>
> 1) My original post has been wrapped. The "Alan" is on the same line in my 
> OpenForm method.
> 2) I tried Me.OpenArgs but no luck, still get the same error.
>

Then for some reason your OpenArg *is* null.  Try stepping through the code 
at run time to find when OpenArgs loses its value.

Keith. 

0
Keith
5/25/2007 7:19:27 AM
Hi again Alan

As Keith has said it would seem that the OpenArgs is really Null and I would 
do as he suggests looking at the value of Me.OpenArgs as you step through 
each line of code.

But, there doesn't look like there is any opportunity for the OpenArgs to 
lose it's value of "Alan".

I just need to check one thing with you. You said "In second form:"  Is this 
second form the form named frmEmployee or a different form altogether?

You are opening frmEmployee with an OpenArgs parameter of "Alan" so you have 
to use Me.OpenArgs in the open event of frmEmployee (not any other form).

Sorry if this is obvious but I'm clutching at straws as I can't see where 
else it could be going wrong!

Regards

Andy Hull


"Alan T" wrote:

> In main form:
> Private Sub btnOpen_Click()
>   DoCmd.OpenForm "frmEmployee", acNormal, , , acFormAdd, acWindowNormal, 
> "Alan"
> End Sub
> 
> In second form:
> Private Sub Form_Open(Cancel As Integer)
>   Dim empName As String
>   empName = Forms!frmEmployee.OpenArgs <-- runt time error
>     If Len(empName ) > 0 Then
>       MsgBox empName
>     Else
>       MsgBox "null"
>   End If
> End Sub
> 
> The runtime error was:
> Invalid use of NULL 
> 
> 
> 
0
Utf
5/25/2007 9:47:02 AM
Hi,

Yes, I specified the frmEmployee is correct.
I also set the button's visible property using the frmEmployee right after 
the OpenForm command.

"Andy Hull" <AndyHull@discussions.microsoft.com> wrote in message 
news:CD9AB0D5-0A3E-49D3-B658-5C39DE25D795@microsoft.com...
> Hi again Alan
>
> As Keith has said it would seem that the OpenArgs is really Null and I 
> would
> do as he suggests looking at the value of Me.OpenArgs as you step through
> each line of code.
>
> But, there doesn't look like there is any opportunity for the OpenArgs to
> lose it's value of "Alan".
>
> I just need to check one thing with you. You said "In second form:"  Is 
> this
> second form the form named frmEmployee or a different form altogether?
>
> You are opening frmEmployee with an OpenArgs parameter of "Alan" so you 
> have
> to use Me.OpenArgs in the open event of frmEmployee (not any other form).
>
> Sorry if this is obvious but I'm clutching at straws as I can't see where
> else it could be going wrong!
>
> Regards
>
> Andy Hull
>
>
> "Alan T" wrote:
>
>> In main form:
>> Private Sub btnOpen_Click()
>>   DoCmd.OpenForm "frmEmployee", acNormal, , , acFormAdd, acWindowNormal,
>> "Alan"
>> End Sub
>>
>> In second form:
>> Private Sub Form_Open(Cancel As Integer)
>>   Dim empName As String
>>   empName = Forms!frmEmployee.OpenArgs <-- runt time error
>>     If Len(empName ) > 0 Then
>>       MsgBox empName
>>     Else
>>       MsgBox "null"
>>   End If
>> End Sub
>>
>> The runtime error was:
>> Invalid use of NULL
>>
>>
>> 


0
Alan
5/28/2007 7:25:31 AM
Having grown tired of watching war movies and listening to martial music this
(in the USA) holiday weekend, I took the time to set up a db to try and
duplicate  Alan's problem. Using his original code(and BTW, Me.OpenArgs and
Forms!frmEmployee.OpenArgs can both be used here) I could only reproduce the
error, as has been suggested, when OpenArgs actually is null!  

I've no idea where "Alan" is disappearing, but anytime there's code
referencing OpenArgs in the opening/loading of a form, there should be a
check to assure that it is not Null! Something like this would cover the
situation here:     

Private Sub Form_Open(Cancel As Integer)
Dim empName As String

'Only assign OpenArgs to empName if it's not Null
If Not IsNull(Me.OpenArgs) Then
   empName = Me.OpenArgs  
End If
 
If Len(empName) > 0 Then
   MsgBox empName
Else
   MsgBox "null"
End If
End Sub

BTW, when referring to a form, within it's own code module, it's probably
good policy to use 

Me.

rather than, as you would here 

Forms!frmEmployee. 

for the simple reason that you're less likely to make a typo error.

-- 
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200705/1

0
missinglinq
5/28/2007 2:21:29 PM
Hi,

So did you manage why the argument is lost?

"missinglinq via AccessMonster.com" <u28780@uwe> wrote in message 
news:72dadb0826f97@uwe...
> Having grown tired of watching war movies and listening to martial music 
> this
> (in the USA) holiday weekend, I took the time to set up a db to try and
> duplicate  Alan's problem. Using his original code(and BTW, Me.OpenArgs 
> and
> Forms!frmEmployee.OpenArgs can both be used here) I could only reproduce 
> the
> error, as has been suggested, when OpenArgs actually is null!
>
> I've no idea where "Alan" is disappearing, but anytime there's code
> referencing OpenArgs in the opening/loading of a form, there should be a
> check to assure that it is not Null! Something like this would cover the
> situation here:
>
> Private Sub Form_Open(Cancel As Integer)
> Dim empName As String
>
> 'Only assign OpenArgs to empName if it's not Null
> If Not IsNull(Me.OpenArgs) Then
>   empName = Me.OpenArgs
> End If
>
> If Len(empName) > 0 Then
>   MsgBox empName
> Else
>   MsgBox "null"
> End If
> End Sub
>
> BTW, when referring to a form, within it's own code module, it's probably
> good policy to use
>
> Me.
>
> rather than, as you would here
>
> Forms!frmEmployee.
>
> for the simple reason that you're less likely to make a typo error.
>
> -- 
> There's ALWAYS more than one way to skin a cat!
>
> Answers/posts based on Access 2000
>
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200705/1
> 


0
Alan
6/5/2007 1:53:17 AM
Reply:

Similar Artilces:

My document opens but all I see is a grey screen.
When I open my file it asks to enable the macros and I say yes. Then it shows opening file at the bottom. However when this is complete and says ready all I have is a grey screen like when you close your document but have Ecel open still. Hi, One thought (and only a thought). Try doing Windows, Arranged, Tiled. This could bring the workbook back. The reason could be that the person saving the sheet had (say) two screens, Excel across both of them and had the workbook on the right hand screen when they saved it. If you have only one screen then the workbook is open, but is posit...

How do I store calculations from a form to a database table?
My boss and I are stuck trying to figure out how to make our calculations be stored in our database table. Currently our calculations are in the design view of the form. We are able to see the anwer to the calculations, but they are not stored in the database table. What are we doing incorrectly? Is there some other place or way that we are supposed to do calculations? Thank you for your help. The short answer is - don't. In most cases you should not try to store calculated values in a table. Calculations should be done in queries or in unbound controls on forms. Storing the value ...

OnLoad form position
While using CRM, I have created a number of custom entities. I know how to set the size using an onLoad script, but is there any way to move the for so that it opens and the user can see everything on the page, rather than opening so that half of the form is off-screen? Any ideas would be greatly appreciated. ...

What ports to open on the firewall
Hi, I am exploring using a terminal server or fat clients and am trying to discover what ports need to be opened on the firewall in order to allow remote users to access the server. If I do not use Terminal Server then what ports will I need to open on the firewall so that the client software can connect to the database server? Also, is it possible to connect the database server and the client over SSL? kwhalley@projects.sdsu.edu ...

Opening up a word attachment error message
A Word file was sent to my e-mail account. I have outlook 2003 installed. When I try to open up the word attachment in outlook, I receive this error message: The server application, source file, or item cannot be found. Make sure the application is properly installed, and that it has not been deleted, moved, or renamed. We are using exchange 2003. Thanks for any help in advance. Peter McCaul <compcoff@hotmail.com> wrote: > A Word file was sent to my e-mail account. I have outlook 2003 > installed. When I try to open up the word attachment in outlook, I > receive th...

My licens is allready in use, by my self....?????
My office 2004, mostly entourage because I start that first in the = morning,=20 often starts with the message, that it is allready in use by "My Name", = but=20 the one who is using it is my self. There is no way that any one is = using my=20 licens, i bought it because I had the problem in office 2003. It can do = it=20 several time a day, but no pattern that I can detect. So if im using it, = is there=20 maby something on the mac, that is started twice, and there for = conflicting? Hope someone has dealed with the problem before, because im on the egde=20 of launching 25 new mac&...

Data Execution Prevention Error -Post use of "GoToMyPC.com"
How can I fix this Error issue: My computer starts shutting down with the following message after being on the computer for 15 minute or more: "Window must now restart because the DCOM Server Process Laucher service terminated unexpectedly" then "Data Execution Prevention - Microsoft Windows To help protect your computer, Windowsw has closed this program. Name: Generic Host Process for Wind32 Services Publisher: Microsoft Corportation" then "Generic Host Process for Win32 Services encountered a problem and needed to close. This pos...

Using a Windows Shortcut to Open to Specific Sheet in Workbook
I want to be able to create a shortcut icon to each individual sheet inside of one workbook. Is this possible? I am aware that there are macros that you can use inside of Excel to make the workbook always open to a specific sheet, but this is not exactly what I am trying to do. I have multiple open jobs at any given time, and I keep information on these jobs in one Workbook. Each job has its own folder on the hard drive. I would like to create a shortcut inside of each folder on the hard drive that opens the same Workbook, but opens it directly to the sheet that correspon...

Can I use the autofilter feature to limit data for a pivot chart?
I have a spreadsheet that I need to use the auto filter feature to display a particular subset of data. I then want to create a pivot chart with the limited data, but using different column and rows than the one filtered. Whenever I try this, my pivot chart picks up the entire spreadsheet contents, not just the filtered data. ...

Show cells that are used for looking up information
I am building a spreadsheet for auditing process improvement progress. It scores people on their adherence to the process on a scale of 0-9. However, it is difficult to remember what the difference between say a 6 and an 8. I have an array of cells on one worksheet in the workbook with definitions of the scores, but its cumbersome to Ctrl-PgUp to get to it. Is there a way to put the score definitions in a pop-up window, a hidden something that shows up and goes away on a macro, etc? The spreadsheet is about 500 lines long, so it would have to be location relative. Thanks in advance, Corey ...

excel file won't open
We have an excel file we've been adjusting for the past week. All of the sudden the file only opens to an hourglass (file never opens and you have to "END TASK") Before we start spending hours searching, does anyone know of any reliable tools we might use to rescue this file? >-----Original Message----- >We have an excel file we've been adjusting for the past week. All of >the sudden the file only opens to an hourglass (file never opens and >you have to "END TASK") Before we start spending hours searching, does >anyone know of any reliable tools w...

Radio button to open recordset
Hello all, I have a form with a subform which is read only. On the subform I have a list of all my records with radio buttons next to them. I would like the user to be able to select the radio button next to a record and select a button to view the full record in a new form so they can edit it. How can this be achieved? I think this is some how going to have to involve recordsets, which I'm not very proficient at. Thanks for any thoughts you can give on this. -- Message posted via http://www.accessmonster.com This doesn't involve recordsets. It is just a matter of opening a ...

How do I change default mail form?
Working in a MS Outlook 2000 Corporate or Workgroup Exchnage Server environment how do I change the default message form that's used for my email? I've created and saved a customised version of teh form, I just need to know how to point the New button at it. -- Regards. Chris. Remove MAPSON to reply to me directly. This post represents the views of the author and does not necessarily accurately represent the views of BT. ...

How do I use double spacing between words instead of one space?
I am doing an assignment and I need to type my work with double spacing between words instead of a single space. How do I adjust the spacing between words On Thu, 29 Apr 2010 15:42:01 -0700, Chiara14 <Chiara14@discussions.microsoft.com> wrote: >I am doing an assignment and I need to type my work with double spacing >between words instead of a single space. How do I adjust the spacing between >words You don't -- not in Word. When you're all done typing, you could use the Replace dialog to replace one space character with two space characters, and clic...

Anyone used service scheduling to manage Hotel or Classroom bookin
I need a simple data entry capability with rooms vertically and a scrollable calendar -- Best wishes WES ...

Outlook Form
Hello, I would like to create something that is automated, and all you have to do it click on this shortcut, and it would have a form that I fill out. Then I could send it via email. If possible, kind of like a outlook template. Everytime we have a new customer, the front office emails us a request for a DSL modem. It normally has info such as Username, password, renting or purchase, phone number, and so on. Can I do this, easily? What should I use? If possible, it would be a form with these fields in it, and it would be great if I could type the info and tab to the next field....

unable to back up using only tape (without disk) with secondary DPM
I have setup a secondary DPM with only tape capabilities (no disk available). When I tried to create a new protection group on the secondary DPM, I unchecked the short term option (disk) and only select the long term option (tape), the "Next" button will get greyed out. Any ideas why is this happening? It happens to all except when I try to protect the Primary DPM or protect itself (secondary DPM). Submitted via EggHeadCafe - Software Developer Portal of Choice C# .NET Windows Task Scheduler http://www.eggheadcafe.com/tutorials/aspnet/9f75423c-4849-4866-ad48-8fbd2ed2ed88/c-...

Losing citations and sources when using track changes and merging
Whenever I use track changes, share my documents between people, get the multiple files back, and merge all files all my citations and sources are lost, and it's a pain to re-enter them. What's going on? ...

Add controls wizard using macros vs. VBA in 2007
When I used to add a button using the wizard to creat the action a VBA script was created. In 2007 I'm getting a macro. Is there a setting somewhere to control which is created? Thanks, Ed ...

Send outlook-email from Access using template (oft)
Dear All, How should i send an outlook-email from access using a template (oft) ? Thanks Write Access VBA code invoking the Application.CreateItemFromTemplate = method from the Outlook object model:=20 Set ol =3D CreateObject("Outlook.Application") Set msg =3D ol.CreateItemFromTemplate("C:\Data\MyTemplate.oft") msg.Display ' or other code to work with msg --=20 Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for=20 Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx &qu...

rare error when consuming .NET web service from ASP 3.0 using ServerXMLHTTP.4.0
I have been working on this problem for several days, and would greatly appreciate any advice I can receive. We have an ASP page that calls a .NET web service we have developed in C++. When we query the web service directly through the generated ASMX file we get the expected XML response. It always works! However, the same queries under the same conditions from our ASP page will sometimes fail. When it does we get the error... "The data necessary to complete this operation is not yet available." We do know that the request can take up to 45 seconds to process, but th...

Saving excelXP file to use on p.c with Excel 97?
Hi i need to save my files i create from my home computer using office Xp to my office p.c which is running office 97. I have tried it but everytime i save my file at work i geta message stating that the file was created on xp and some latest features may be missing. How i can save so i do not get this message or indeed if i can actually do it? Thanks in advance I don't think you can avoid the message - the important point would be to use features common to both - then you may get the message, but it would be of no consequence. -- Regards, Tom Ogilvy Mena <etracing@netconnect...

way to open a form in mutliple instances?
Is there a way to open up a form in more than one instance. i.e. the same form but different data? If so, what is the methos? Thanks for any help. Yes, there is. See the sample code at http://www.daiglenet.com/msaccess.htm The Multi_Instance Forms download is the last one on this page. HTH, Rob "ThorBo" <ThorBo@discussions.microsoft.com> wrote in message news:0296148F-5664-4584-90D6-CDE1BCCC3DED@microsoft.com... > Is there a way to open up a form in more than one instance. i.e. the same > form but different data? If so, what is the methos? > > Thanks for ...

How to use my Outlook
I use msn8 but I can not use my outlook mail. I keep getting an error message about my POP3 account. ...

form creating new row in table1, looking for field value in table
Please can someone help as I have been battling all week with this problem, and haven't had a response. I have a form which uses some data from table1 to create an entry in table2 (i know duplication is bad, but as this is a live database, and i am working on a new section, this makes this complicated task easier), which works fine. however, i have a third table that has the unique ID from table1 and table2 in order to show when a table1 row of data is needed in table2 via a checkbox. This third table3 is created when elsewhere. The problem lies with bringing in the unique ID value...