Different Form Names OnOpen (1 Viewer)

Adrianna

Registered User.
Local time
Yesterday, 21:45
Joined
Oct 16, 2000
Messages
254
Okay I'm maintaining a database that has one from which can be opened in Edit mode or Add mode from the switchboard. The users have requested that the Form Name in the title bar coincide with the MODE that they have opened the form in.

So, I want to be able to have the title bar read Adding New Records (in add mode) and Editing Existing Records (in Edit mode), but I'm not familiar with where I would do this.

Please advise!

Thanks!
 

ghudson

Registered User.
Local time
Yesterday, 21:45
Joined
Jun 8, 2002
Messages
6,195
You would use this to change the forms caption...

Me.Form.Caption = "Adding New Records"

For how you switch the caption is up to you but you could have the mode "Add/Edit" checked when the form is opened.

Private Sub Form_Open(Cancel As Integer)
If Me.AllowAdditions = True Then Me.Form.Caption = "Adding New Records"
If Me.AllowEdits = True Then Me.Form.Caption = "Editing Existing Records"
End Sub
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 21:45
Joined
Feb 19, 2002
Messages
43,478
I would check the NewRecord property in the form's current event.

If Me.NewRecord = True Then
Me.Form.Caption = "Adding New Records"
Else
Me.Form.Caption = "Editing Existing Records"
End If
 

Adrianna

Registered User.
Local time
Yesterday, 21:45
Joined
Oct 16, 2000
Messages
254
Shot Down Twice:(

Okay...I tried them both:

If (Me.AllowAdditions = True) Then
Me.Form.Caption = "Enter New System Records"
Else
If (Me.AllowAdditions = False) Then
Me.Form.Caption = "Edit Existing Records"
End If
End If
(ALWAYS OPENS WITH "ENTER NEW....")

AND THEN:

If Me.NewRecord = True Then'Me.Form.Caption = "Enter New System Records"
Else
Me.Form.Caption = "Edit Existing Records"
End If

(ALWAYS OPENS WITH "EDIT EXISTING...")

So....I tried to go into the switchboard and adit the code to set the second OpenFrom to acFormEdit because the first one is acAdd

I've tried a few other things, but i can't seem to get this to work. I think that NewRecord Method doesn't work because I have default values that possibly makes the form think that a new record has already been started (meaning that you're adding to it..not starting from scratch).:confused:
 

ghudson

Registered User.
Local time
Yesterday, 21:45
Joined
Jun 8, 2002
Messages
6,195
Adrianna,

Did you try my code "as is"? The code you posted is not what I gave you.

Private Sub Form_Open(Cancel As Integer)
If Me.AllowAdditions = True Then Me.Form.Caption = "Adding New Records"
If Me.AllowEdits = True Then Me.Form.Caption = "Editing Existing Records"
End Sub

My code is testing to see what mode the form was opened in.

It works in my attached example.
 

Attachments

  • addedittest.zip
    14.3 KB · Views: 90

Adrianna

Registered User.
Local time
Yesterday, 21:45
Joined
Oct 16, 2000
Messages
254
ghudson,
I appreciate the example, but I'm not going about it the same way that you are. if I had to separate forms that it would be ease to make the titles/captions appear differently.
I have ONE from that is opened from the switchboard in either acAdd or acFromEdit mode. So, I need to determine which state the database is in and then adjust the title/caption accordingly.

I did try your code just the way it was, but it always remains in "EDIT EXISTING..." This is because the allowedits is set to YES on the form itself. I need to find a way to tell the switchboard what to do with the caption....depending on the mode it opens it in.
:confused:
 

ghudson

Registered User.
Local time
Yesterday, 21:45
Joined
Jun 8, 2002
Messages
6,195
I see your problem. Try this example. The swithboard opens the form and tests the value of the "tbAddEdit" text box in the switchboard to see if it is Add or Edit. Depending on the value of the tbAddEdit text box, it opens the "AddOrEdit" form in Add or Edit mode and the forms caption correctly displays that fact.

HTH
 

Attachments

  • addedittest.zip
    15.4 KB · Views: 96

Adrianna

Registered User.
Local time
Yesterday, 21:45
Joined
Oct 16, 2000
Messages
254
GHudson!

Hehe....I tried it and it didn't work....but then I realized what I was doing wrong. :rolleyes: Sorry to have asked so many times. I hate being the one to frustrate people, but I guess we all have our turns. I have an alert report that runs before the "EDIT" version of the form. So, when I tried to run the initial code...and the latest idea that you provided me.....the value wasn't being passed to the right place!
I really appreciate your help and patients!

Thanks:D
 

ghudson

Registered User.
Local time
Yesterday, 21:45
Joined
Jun 8, 2002
Messages
6,195
Did my 2nd example db work for you "as-is"?

Does your report care if the form is opened in Add or Edit mode?

Can you post the code you are using from your switchboard to print the report and open the form in Add or Edit mode and pass the Add or Edit value?

Is the code in your AddEdit form correctly referrencing the "tbAddEdit" text box in the SwitchBoard?

If Forms!SwitchBoard!tbAddEdit = "Add" Then
If Forms!SwitchBoard!tbAddEdit = "Edit" Then
 

Adrianna

Registered User.
Local time
Yesterday, 21:45
Joined
Oct 16, 2000
Messages
254
GHudson,
Oh...I thought that I said THANK YOU!

I figured it out. It worked. I hadn't thought about using the unbound text box to set a value and have the form check for it. All went well:) No more problems;)

:D
 

Users who are viewing this thread

Top Bottom