473,320 Members | 1,732 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,320 software developers and data experts.

Trouble with zero-length string error using OpenArgs

55
I'm having a zero-length string problem... Hoping someone can help. (This is in Access 2000.)

In FormA, I have a button that opens FormB with OpenArgs. In FormB, the OpenArgs are translated into default values for certain controls.

FormB is a continuous form. For this reason, I can't assign .Value -- it has to be .DefaultValue. Otherwise it changes the values in the first record in the form.

If any of the transferred controls in FormA has no data, then there's of course no data in the corresponding default value in FormB. Apparently Access is reading this as a 'zero-length string' in FormB, and it gives me an error message (Field tbl.fld cannot be a zero-length string) when I try to save the new record in FormB.

How do I get it to read Null values in FormA as Null in FormB? I haven't been able to figure it out.

Here's my code:

In FormA:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdButton_Click()
  2.  
  3.     Dim stDocName As String
  4.     Dim stLinkCriteria As String
  5.  
  6.     stDocName = "Add Job"
  7.     DoCmd.OpenForm stDocName, , , stLinkCriteria, , , OpenArgs:=txtInfo1 & "|" & txtInfo2 & _
  8.         "|" & txtInfo3
  9.  
  10. End Sub
Module:
Expand|Select|Wrap|Line Numbers
  1. Public Function ParseText(TextIn As String, x) As Variant
  2. On Error Resume Next
  3. Dim Var As Variant
  4. Var = Split(TextIn, "|", -1)
  5. ParseText = Var(x)
  6.  
  7. End Function
In FormB:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3. If Not IsNull(Me.OpenArgs) Then
  4.     Dim strText1 As String
  5.     Dim strText2 As String
  6.     Dim strText3 As String
  7.  
  8.     strText1 = ParseText(OpenArgs, 0)
  9.     strText2 = ParseText(OpenArgs, 1)
  10.     strText3 = ParseText(OpenArgs, 2)
  11.  
  12.     Me.txtFirst.DefaultValue = "=" & """" & strText1 & """"
  13.     Me.txtSecond.DefaultValue = "=" & """" & strText2 & """"
  14.     Me.txtThird.DefaultValue = "=" & """" & strText3 & """"
  15.  
  16.  
  17. End If
  18.  
  19. End Sub
Thanks for any help you can offer!
Angi
Aug 8 '08 #1
3 2162
missinglinq
3,532 Expert 2GB
To be honest, I'm a little confused as to what's giving you the zero-length strings here, insteasd of nulls, and the form being continuous view is neither here nor there. But what you need to do, I guess, is to check before assigning your Default Values, something like this:

Expand|Select|Wrap|Line Numbers
  1. If  strText1 <> "" Then 
  2.   Me.txtFirst.DefaultValue = "=" & """" & strText1 & """"
  3. End If
  4.  
Linq ;0)>
Aug 8 '08 #2
angi35
55
What a relief. It works. I figured it would be something like this, but the whole null/empty/zero-length string thing makes my head spin, and I just could not get Access to understand what I was trying to tell it. Really appreciate the help!

Angi
Aug 8 '08 #3
missinglinq
3,532 Expert 2GB
Glad we could help!

Linq ;0)>
Aug 8 '08 #4

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

Similar topics

9
by: Alexander Stippler | last post by:
Hi, I've got trouble with some well known issue. Iterator invalidation. My situation: for (it=v.begin(); it!=v.end(); ++it) { f(*it); } Under some circumstances, f may alter the container...
27
by: ncf | last post by:
Hi all. In another topic, I was informed that I had to dynamically allocate memory instead of just trying to expand on a list. (I'm trying to learn C, and have a strong background in PHP and...
1
by: Dirk Vervecken | last post by:
Hi, I'm trying to fill a dataRow from a dataset. But now i'm wondering, what do i do if the Dataset does not contain the requested information? For Example : c_CompGroupRij =...
0
by: lkrubner | last post by:
The idea I'm trying to get at is that I want the tag info for the tag "photography", and I want the date, and I want a count of any comments a tag may have. This following query gets back all the ...
2
by: eric.houghland | last post by:
Hello, I've read quite a bit about implementing this interface in .NET and believe I have a good start. I am able to use StgIsStorageFile, StgCreateStorage and StgOpenStorage. I am now...
7
by: MLH | last post by:
This was contributed by someone in this NG last year... Sub WaitFor(psngSeconds As Single) ' wait for specified number of seconds ' Copyright Trevor Best (tre...@besty.org.uk) <-OK, so I added...
10
by: Hendri Adriaens | last post by:
Hi, I'm trying to automate the creation of an excel file via COM. I copied my code below. I read many articles about how to release the COM objects that I create. The code below runs just fine...
4
by: Nick Keighley | last post by:
Hi, is this correct:- typedef struct { long frequency; } Structure; Structure my_struct = {0};
4
by: H.S. | last post by:
Hello, I am trying out a few methods with which to test of a given number is practically zero. as an example, does the following test correctly if a given number is zero within machine...
39
by: rembremading | last post by:
Hi all! The following piece of code has (for me) completely unexpected behaviour. (I compile it with gcc-Version 4.0.3) Something goes wrong with the integer to float conversion. Maybe somebody...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.