Solved how to properly check for a combobox value on one form from a pop up form? (1 Viewer)

mamradzelvy

Member
Local time
Today, 20:04
Joined
Apr 14, 2020
Messages
145
Hi,
I have a form that tracks our currently pending invoices.
In order to "finalise" an invoice (set its Status from 0 to -1) i've got a pop-up form that has 3 buttons on it.
Each button applies the -1 value into diferent records, one button takes a single selection from the underlying listbox from the mainform and UPDATEs it's Status, second button applies it to all that are currently active (status = 0) and the last one is supposed to apply it only to all active members of any given selected client from a combobox selection i have present on the main form.
However despite my best efforts to check whether there has been any selection in said combo box i have failed thus far.

What's wrong with my code?

Code:
Private Sub btnClientWide_Click()
If Forms!formTabuleMini!txtKlient.Value = Null Then
  MsgBox "No selection!" & vbCrLf & vbCrLf & "Go back and select a client from the dropdown menu in order to use this function.", vbInformation, "Error!"
  Else
DoCmd.RunSQL "UPDATE Tabule1 SET TabStatus = '-1', TabDate2 = Now() WHERE TabKlient LIKE '" & Forms!formTabuleMini!txtKlient & "*' AND TabStatus LIKE 0;"
Globals.Logging "Tabule - Client Wide Finalisation"
End If
End Sub

also a part of my on load event i have got Me.txtKlient.Value = Null to make sure the value is in fact NULL
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:04
Joined
Sep 21, 2011
Messages
14,046
Well I wouldn't be using LIKE, but you have no asterisk for Tabstatus?
I would be using = ?

I also set boolean to True or False and let access choose what that is.?
 

mamradzelvy

Member
Local time
Today, 20:04
Joined
Apr 14, 2020
Messages
145
Well I wouldn't be using LIKE, but you have no asterisk for Tabstatus?
I would be using = ?

I also set boolean to True or False and let access choose what that is.?
The query works just nice, it's the "IF" statement that doesn't work for me.
 

Minty

AWF VIP
Local time
Today, 19:04
Joined
Jul 26, 2013
Messages
10,355
This line
If Forms!formTabuleMini!txtKlient.Value = Null Then
Won't work nothing = Null

You need to use If IsNull(Forms!formTabuleMini!txtKlient) Then
 

mamradzelvy

Member
Local time
Today, 20:04
Joined
Apr 14, 2020
Messages
145
This line
If Forms!formTabuleMini!txtKlient.Value = Null Then
Won't work nothing = Null

You need to use If IsNull(Forms!formTabuleMini!txtKlient) Then
Thank you, as per usual, this has worked!
But what's the diference between these two?
 

Minty

AWF VIP
Local time
Today, 19:04
Joined
Jul 26, 2013
Messages
10,355
Null is a peculiar thing, it doesn't equal anything. The fact it doesn't can be useful.
In the immediate window you can type all sorts of gibberish to test things;

? IsNull("")
False
? 0 + Null
Null

So whilst you can SET certain things to null you can't ask if something is equal to Null. Hence the special VBA IsNull() function, to allow you to test for it.
 

Users who are viewing this thread

Top Bottom