Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to exit edit mode not null? 1

Status
Not open for further replies.

ailyn

Programmer
Sep 15, 2005
108
BE
I have a form that is reloaded as in edit mode with one button and in nonediting mode with another. But to avoid trouble with null values (in case the user has erased the value he was editing) I need to filter the exiteditmodebutton command:

Private Sub ExtEditMode_Click()
On Error GoTo Err_ExtEditMode_Click

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Products"
Dim f As Form
If IsNull([ProductId]) Then
stLinkCriteria = "[ProductId]"
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
Else
DoCmd.OpenForm stDocName, , , , acFormReadOnly
End If
MsgBox "Read Only Mode Activated"

Set f = Forms(stDocName)
f.MkProduct.Visible = False
f.Bij17.Visible = False
f.SvProduct.Visible = False
f.Bij18.Visible = False
f.DltProduct.Visible = False
f.Bij19.Visible = False

Exit_ExtEditMode_Click:
Exit Sub

Err_ExtEditMode_Click:
MsgBox Err.Description
Resume Exit_ExtEditMode_Click

End Sub


This is my code. I just need to know how to change the link criteria apropriately, so that it shows all the good records again.
Help, pls!
 
Look for "OpenArgs" in the help file.

________________________________________________________
Zameer Abdulla
Help to find Missing people
My father was a realistic father; not a vending machine dispense everything I demanded for!!
 
Sorry for my ignorance but after following the instructions of the help file, it doesn't work.

Here is my code:

Sub OpenToProducts()
DoCmd.OpenForm "Products", acNormal, , , acReadOnly, _
, "1"

End Sub


Private Sub ExtEditMode_Click()
On Error GoTo Err_ExtEditMode_Click

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Products"
Dim f As Form

Dim strName As String
' If OpenArgs property contains employee name, find
' corresponding employee record and display it on form. For
' example,if the OpenArgs property contains "Callahan",
' move to first "Callahan" record.
strName = Forms!Products.OpenArgs
If Len(strName) > 0 Then

DoCmd.GoToControl "ProductId"
DoCmd.FindRecord strName, , True, , True, , True
End If





'If IsNull([ProductId]) Then
'stLinkCriteria = "[ProductId]"
'DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
'Else
'DoCmd.OpenForm stDocName, , , , acFormReadOnly
'End If
MsgBox "Read Only Mode Activated"

Set f = Forms(stDocName)
f.MkProduct.Visible = False
f.Bij17.Visible = False
f.SvProduct.Visible = False
f.Bij18.Visible = False
f.DltProduct.Visible = False
f.Bij19.Visible = False

Exit_ExtEditMode_Click:
Exit Sub

Err_ExtEditMode_Click:
MsgBox Err.Description
Resume Exit_ExtEditMode_Click

End Sub

I don't know what's wrong. The error msg says 'invalid use of null'. All I want is to show all the other available values in products not to focus on one, but rather not to focus on a null value. What should I do?
 
Ok, I solved it without the openArgs to avoid focusing. I just reboot it:

Private Sub ExtEditMode_Click()
On Error GoTo Err_ExtEditMode_Click

Dim stDocName As String

stDocName = "Products"
'Dim f As Form
DoCmd.Close acForm, stDocName
DoCmd.OpenForm stDocName, acNormal, , , acFormReadOnly, acWindowNormal

Exit_ExtEditMode_Click:
Exit Sub

Err_ExtEditMode_Click:
MsgBox Err.Description
Resume Exit_ExtEditMode_Click

End Sub

Thanks a lot anyway Zameer!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top