Full Version: form on current command
UtterAccess Forums > Microsoft® Access > Access Forms
mtc
I have a sub form and in that subform there's a command. The code for that command is
Private Sub Form_Current()
If IsNull(ID) Or IsNull(Amount) Or IsNull(SoldBy) Then
Command26.Enabled = False
Else: Command26.Enabled = True
End If
End Sub
want to duplicate this command, but I don't know how to add it to this code, which appears in the "on current" event in the subform properties. I have duplicated it but had to put this code (diffrent name) in the "on open" in the event tab. I really would like to add it to the top code as I am finding a need to add yet a third command. It is a print command, and I have 3 diffrent invoices now. Hence the ned for 3 separate commands.
Thanks
Jack Cowley
I'm sorry, but I do not understand your question. What is 'top code' and what do 3 different invoices have to do with the code in the On Current event?...Hmmm. Maybe I just guessed it.... You want to add more command buttons to the code so they will be hidden for visible... If this is the case then I would do it differently. I would have a list box of invoices and a single command button. Let the user select the invoice they want to print and then click the single command button. This would be a better approach because what if next week you need to add a fourth invoice to print? With your current setup you have to modify your form, but with my suggestion you could easily add more invoices and not have to change a thing on the form..
Am I making sense?
Jack
mtc
I see what your saying, but this is a somewhat complicated database. It is for my fundraiseing business, and I'm sorry to say that a number of programmers have had thier go at it. Each one adding to the DB until I have what I need to keep my business running. A coupe of programmers have quoted a pretty penny to bring it up to date, but honestly I just don't have that kind of scratch.
This form is a sub form of a main form. The main form contains the person personal info, the subform contains thier donation history. The command is actually a secondary print option. As the main printing of invoices are done daliy and in large quantity (something most people including programmers don't seem to get right away) this command button is if I ever need to print a single invoice for a certain person. Therefore it is connected in some way to the main print funtion pulling from the command what it needs to print a single invoice.
My problem is when I added a second command, I could not put the code above in the "on current" event because the first command button was taking that spot. Or in the code I've provided command26.
My question is can I add command27 to the code above. I've tried adding it into the code but I get error messaages when I use, &, and etc.
Now your suggestion is ok, but in my business in 13 years I have used about 2 or 3 invoices. So 2 or 3 buttons or a drop down list? 6 of one. I'm just trying to add on to my DB as it is. And someday somehow I will be able to get it all revamped.
Thanks
Regards
Mike
Jack Cowley
Mike -
Y-
Your current code reads:
If IsNull(ID) Or IsNull(Amount) Or IsNull(SoldBy) Then
Command26.Enabled = False
Else: Command26.Enabled = True
End If
If you want the same criteria for Command 27 then:
If IsNull(ID) Or IsNull(Amount) Or IsNull(SoldBy) Then
Command26.Enabled = False
Command27.Enabled = False
Else
Command26.Enabled = True
Command27.Enabled = True
End If
If you want different criteria for each button:
If Something Is True Then
Me.Command27.Enabled = False
Else
Me.Command.27.Enabled = True
End if
If IsNull(ID) Or IsNull(Amount) Or IsNull(SoldBy) Then
Command26.Enabled = False
Else: Command26.Enabled = True
End If
I hope I am understanding your question as you should be able to put code similar to this in your On Current event and it should work... If this does not do the trick then show me what you tried that did not work...
Jack
mtc
That works perfect! Thank you very much. Regards Mike
Jack Cowley
Mike -
You are most welcome and I am glad to hear that the suggestion(s) worked for you. Continued success with your database project...
Jack
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.