Solved Missing operator in Dmax (1 Viewer)

oxicottin

Learning by pecking away....
Local time
Yesterday, 20:07
Joined
Jun 26, 2007
Messages
851
Hello im getting an error 3075, what am I missing

DMax("ItemSeqNumber", "tbl_MenuItems", "[MenuID] = " & Me.MenuID) + 1
 

Attachments

  • error.JPG
    error.JPG
    11 KB · Views: 92

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:07
Joined
Oct 29, 2018
Messages
21,358
You could add Nz(). For example:
Code:
 DMax("ItemSeqNumber", "tbl_MenuItems", "[MenuID] = " & Nz(Me.MenuID,0)) + 1
 

CJ_London

Super Moderator
Staff member
Local time
Today, 00:07
Joined
Feb 19, 2013
Messages
16,553
to expand on dbg's suggestion, the error is telling you that me.MenuID is null
 

Isaac

Lifelong Learner
Local time
Yesterday, 17:07
Joined
Mar 14, 2017
Messages
8,738
In case MenuID might contain a ZLS in addition to a Null, you may want to accommodate both possibilities -

Code:
DMax("ItemSeqNumber", "tbl_MenuItems", "[MenuID] = " & iif(("" & Me.MenuID)="",0,Me.MenuID) + 1

I never remember the various scenarios where controls are or aren't likely to contain a zero length string, but I'm pretty sure it could happen on a bound control where the control initially held a value, but then was deleted off of it using the keyboard at runtime.

I did test it and you'll get the same error in cases where MenuID is a blank string.

Just in case.
 

oxicottin

Learning by pecking away....
Local time
Yesterday, 20:07
Joined
Jun 26, 2007
Messages
851
Ok I got it to semi work now! Now it works correctly UNLESS its a new menu with no records then I get an error:
Run-time error '2427':
You entered an expression that has no value.


Here is how I get the error. If you open (frm_MenuEditor) and in the combo box select an existing name and select "Test Menu One". As you see I have no records associated with this menu yet so nothing populates in the subform. Select the "Add A New Item" to add a record. This is where the error is and its only if I haven't created records yet. If you go through the other menus like "Main Menu" Or "Administration" and click the "Add A New Item" button then it creates a new record with the next (txtItemSeqNumber). How do I get around this?
 

Attachments

  • TEST Menu.accdb
    1.6 MB · Views: 69

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:07
Joined
Oct 29, 2018
Messages
21,358
Ok I got it to semi work now! Now it works correctly UNLESS its a new menu with no records then I get an error:
Run-time error '2427':
You entered an expression that has no value.


Here is how I get the error. If you open (frm_MenuEditor) and in the combo box select an existing name and select "Test Menu One". As you see I have no records associated with this menu yet so nothing populates in the subform. Select the "Add A New Item" to add a record. This is where the error is and its only if I haven't created records yet. If you go through the other menus like "Main Menu" Or "Administration" and click the "Add A New Item" button then it creates a new record with the next (txtItemSeqNumber). How do I get around this?
Hope this helps...
 

Attachments

  • TEST Menu.zip
    88.1 KB · Views: 86

oxicottin

Learning by pecking away....
Local time
Yesterday, 20:07
Joined
Jun 26, 2007
Messages
851
@theDBguy, It's still not doing what I needed it to do BUT the error is gone now 👍. The menu name is created so I should be able to add a record (Add A New Item) before you fixed that without the error '2427' because in the table (tbl_MenuItems) the ItemSeqNumber is 0 and not null so the DMax should see that and add +1 so the first records ( ItemSeqNumber) for that menu is 1

Thoughts?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:07
Joined
Oct 29, 2018
Messages
21,358
@theDBguy, It's still not doing what I needed it to do BUT the error is gone now 👍. The menu name is created so I should be able to add a record (Add A New Item) before you fixed that without the error '2427' because in the table (tbl_MenuItems) the ItemSeqNumber is 0 and not null so the DMax should see that and add +1 so the first records ( ItemSeqNumber) for that menu is 1

Thoughts?
Sorry, I thought you were only concerned about getting rid of the error, so that's all I did.

I'll take another look later.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:07
Joined
Oct 29, 2018
Messages
21,358
Sorry, I thought you were only concerned about getting rid of the error, so that's all I did.

I'll take another look later.
Okay, please try again and let us know if this is any close to what you want. Cheers!
 

Attachments

  • TEST Menu (2).zip
    90.2 KB · Views: 65

oxicottin

Learning by pecking away....
Local time
Yesterday, 20:07
Joined
Jun 26, 2007
Messages
851
@theDBguy.... Yep you got it!!! Thank You 🍻

Is all you added was the Nz(Me.Parent.cboMenuName, 0) Or was there something else?
 

Users who are viewing this thread

Top Bottom