how to fix invalid use of null ? (1 Viewer)

Dlovan-IT

Registered User.
Local time
Today, 18:19
Joined
Oct 9, 2013
Messages
84
hello every one

i make the database for the fast food place , i have problem with the listbox , in the main form when opening you see all the tables of the restaurant for right know i active table 1 and table 2 , when click on the table it should be display all the item but the problem when i click on the table say "invalid use of null" i don't no what is problem please check my database in the attachment


regards
 

Attachments

  • 32.zip
    157.9 KB · Views: 90

Chungalin

New member
Local time
Today, 17:19
Joined
Jun 1, 2014
Messages
5
In frmSell:

Code:
Private Sub Form_Load()
List11.RowSource = "select * from table1 where tableno=" + "'" + Text9 + "'"
End Sub
Text9 (unbound textbox, labeled as "Table number") is Null and that causes the error.

When you click on table button...
Code:
Private Sub com1_Click()
DoCmd.OpenForm "frmSell"
Forms!frmSell!Text9.Value = com1.Caption
End Sub
...frmSell’s Form_Load executes before you assign a value to Text9, so at that point it’s still Null.

I can propose you to use OpenArgs argument in OpenForm to pass the table number to frmSell.
 

Dlovan-IT

Registered User.
Local time
Today, 18:19
Joined
Oct 9, 2013
Messages
84
thanks @Chungalin for your reply , can you explain me how to use OpenArgs argument to pass the table number ? or can you do it for me , so that to know me how you do it
 

Chungalin

New member
Local time
Today, 17:19
Joined
Jun 1, 2014
Messages
5
I’m telling you where to fish, but you’re asking me for the fish... ;)

In code window, move the cursor over DoCmd.OpenForm and press F1. Read what OpenArgs is and then click on OpenArgs help page, there’s a sample code too!

Code:
Private Sub com1_Click()
  DoCmd.OpenForm "frmSell", , , , , com1.Caption
End Sub
Code:
Sub Form_Open(Cancel As Integer)
  If Not IsNull(OpenArgs) Then
    Text9.Value = OpenArgs
    List11.RowSource = "select * from table1 where tableno=" + "'" + Text9 + "'"
  End If
End Sub
 

Dlovan-IT

Registered User.
Local time
Today, 18:19
Joined
Oct 9, 2013
Messages
84
thanks dear for take me the fish :)

but you know when i doing the openargs the second form was not opening ! are you testing it ? it is better pass the parameter and open form
 

Chungalin

New member
Local time
Today, 17:19
Joined
Jun 1, 2014
Messages
5
This happens when one just copies+pastes without understanding it.:rolleyes:

In DoCmd.OpenForm call there’re 5 commas. Should be 6.
 

Dlovan-IT

Registered User.
Local time
Today, 18:19
Joined
Oct 9, 2013
Messages
84
yeah you are right dear , i trying too much to knowing that , wonderful my problem was solved
 

Users who are viewing this thread

Top Bottom