Userform Command Button not available until another command buttonhas been used

M

MiataDiablo

I have a userform that has an Add New Record command button and a
Submit command button. I don't want the Submit button to be available
until/unless the Add New Record has been used. I'm not sure how to go
about writing the code for that. Currently, the user can "browse"
thru existing records using my Previous and Next command buttons but I
don't want them to be able to edit the record they're viewing (at this
time, ultimately I do but I can't figure out the code for that
either), but in the meantime I would be content with disabling the
Submit button.

Any suggestions are greatly welcomed.
 
B

Barb Reinhardt

I'd probably create a named range called EnableSubmit and change it when
needed.

At the beginning of the Submit code, you could read the value for the range
and if it's TRUE, continue.
 
M

MiataDiablo

I'd probably create a named range called EnableSubmit and change it when
needed.  

At the beginning of the Submit code, you could read the value for the range
and if it's TRUE, continue.
--
HTH,
Barb Reinhardt






- Show quoted text -

That sounds great but I can't get my head around it, do you have a
minute that you could explain how I would do that or point me in the
right direction?
 
B

Barb Reinhardt

This should help you get started.

Sub ReadSubmit()

Dim Submit As String
On Error Resume Next
Submit = Evaluate(Names("Submit").Value)
On Error GoTo 0
If Submit = "" Then
Debug.Print "Named range submit doesn't exist"
Else
Debug.Print "Submit: " & Submit
End If
End Sub

Sub DefineSubmit()
Dim myName As String
Dim myRefersTo As String
'Change submit to Yes
myName = "Submit"
myRefersTo = "=""Yes"""
ThisWorkbook.Names.Add Name:=myName, RefersTo:=myRefersTo

Call ReadSubmit
'Change submit to No
myName = "Submit"
myRefersTo = "=""No"""
ThisWorkbook.Names.Add Name:="Submit", RefersTo:="=FALSE"
End Sub
 
M

MiataDiablo

This should help you get started.

Sub ReadSubmit()

Dim Submit As String
On Error Resume Next
Submit = Evaluate(Names("Submit").Value)
On Error GoTo 0
If Submit = "" Then
    Debug.Print "Named range submit doesn't exist"
Else
    Debug.Print "Submit: " & Submit
End If
End Sub

Sub DefineSubmit()
Dim myName As String
Dim myRefersTo As String
'Change submit to Yes
myName = "Submit"
myRefersTo = "=""Yes"""
ThisWorkbook.Names.Add Name:=myName, RefersTo:=myRefersTo

Call ReadSubmit
'Change submit to No
myName = "Submit"
myRefersTo = "=""No"""
ThisWorkbook.Names.Add Name:="Submit", RefersTo:="=FALSE"
End Sub

--
HTH,
Barb Reinhardt






- Show quoted text -

That definitely gets me started. I'm a VBA newbie so I understand
what I need to do, but not how to get there. Thanks a million!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top