[AccessD] Recordset method Failed
Gustav Brock
gustav at cactus.dk
Tue Sep 12 01:12:50 CDT 2017
Hi David
Have in mind please, that an unbound combobox always returns Null for no selection or a string for any selection.
Thus, you should use:
If Nz(Me!cboFilter, "") = "" Then MsgBox "Empty string"
or, as the default return value for Nz is an empty string, simply:
If Nz(Me!cboFilter) = "" Then MsgBox "Empty string"
or, to make clear that you pull the value of the combobox:
If Nz(Me!cboFilter.Value) = "" Then MsgBox "Empty string"
If you wish to use zero, it should either read:
If Nz(Me!cboFilter, 0) = 0 Then MsgBox "Empty string"
or rather:
If Nz(Me!cboFilter, "0") = "0" Then MsgBox "Empty string"
/gustav
-----Oprindelig meddelelse-----
Fra: AccessD [mailto:accessd-bounces at databaseadvisors.com] På vegne af David Emerson
Sendt: 12. september 2017 06:37
Til: 'Access Developers discussion and problem solving' <accessd at databaseadvisors.com>
Emne: Re: [AccessD] Recordset method Failed
I have been doing more investigating and have come up with something unusual.
The IT people have set up a separate box with SQL 2008R2 installed cleanly and Access 2010 installed cleanly. Some of the problems have gone away with setting the record sets of forms and combo boxes. I have found that I am now getting an unusual thing happening when I use some of the combo boxes for filters.
The combo boxes are basically 2 columns with the first column being an ID and the second column being a text description.
When I select an item from the list the combo box has the value of the ID for that item.
If I clear the combobox and use nz to get the value of the box (for example
nz(me!cboFilter,0)) I get 0 on my development machine but the new server returns an empty string. I know this because I had this on the After Update
event:
MsgBox "(" & Nz(Me!cboFilter, 0) & ")"
If Nz(Me!cboFilter, 0) = "" Then MsgBox "Empty string"
On My machine I get:
(0)
On the new server I get
()
Empty String
Why the different behaviour? Is this a setting, or something with NZ I am not aware of?
Regards
David Emerson
Dalyn Software Ltd
Wellington, New Zealand
More information about the AccessD
mailing list