P
Pamela
I have a cbo ShopName on my subform which is populated by ltblShop. The cbo
displays the Name, but is bound by the ShopID. If the user doesn't enter a
value, I want a msgbox to open confirming this and then entering "None",
which is an item in my ltblShop. Admittedly, the idea of having a tbl for
Shops which then has a "None" entry which isn't a shop feels wrong but seemed
to be the most expedient at the time and easiest for such the novice that I
am. The code for this upon entering and exiting that control seems to work
fine. The box opens upon a Null entry and will put "None" as directed. The
problem comes in when I later refer to that control in code to concatenate it
into text to copy. The copy operation gives me a "The operation has been
canceled" error and then I get "The value entered isn't valid..." error and
the system sets focus back to this control.
Here is my code:
Private Sub ShopName_Exit(Cancel As Integer)
If Len(Me.ShopName & vbNullString) = 0 Then
If MsgBox("Are you sure there's no shop?", vbYesNo, "Enter Shop") =
vbYes Then
Me.ShopName = "None"
Else
Me.ShopName.SetFocus
End If
End If
End Sub
**Note, if a ShopName is entered, the whole form works perfectly - it's only
on this "None" portion that it stops up.
Thanks so much for help!!
Pamela
displays the Name, but is bound by the ShopID. If the user doesn't enter a
value, I want a msgbox to open confirming this and then entering "None",
which is an item in my ltblShop. Admittedly, the idea of having a tbl for
Shops which then has a "None" entry which isn't a shop feels wrong but seemed
to be the most expedient at the time and easiest for such the novice that I
am. The code for this upon entering and exiting that control seems to work
fine. The box opens upon a Null entry and will put "None" as directed. The
problem comes in when I later refer to that control in code to concatenate it
into text to copy. The copy operation gives me a "The operation has been
canceled" error and then I get "The value entered isn't valid..." error and
the system sets focus back to this control.
Here is my code:
Private Sub ShopName_Exit(Cancel As Integer)
If Len(Me.ShopName & vbNullString) = 0 Then
If MsgBox("Are you sure there's no shop?", vbYesNo, "Enter Shop") =
vbYes Then
Me.ShopName = "None"
Else
Me.ShopName.SetFocus
End If
End If
End Sub
**Note, if a ShopName is entered, the whole form works perfectly - it's only
on this "None" portion that it stops up.
Thanks so much for help!!
Pamela