Popup form help

stevekos07

Registered User.
Local time
Today, 08:22
Joined
Jul 26, 2015
Messages
174
Hello. I have a continuous form which is used to record client messages. I have the form placed in another form as a subform, whereby the form displays the message history of the client shown in the form. This works fine, with the last record in the list being a blank record ready to be edited.

I have the same form opening from a command button in another form as a popup. This form also opens displaying the message history for the client in question, but in this case the last message is blank, with no client ID pre-filled. If the user tries to edit the message by entering the client ID an error message appears regarding a query syntax error.

I have tried to correct this by modifying the macro on the command button, by ensuring that the form opens to Add mode etc. but I have not been able to fix this problem.

This is the Popup version. Notice that the last record has no client ID.

bd9feb61-9540-4728-9e83-ad56f15372eb.png


And this one is the same form as a subform showing a new record with the clientID pre-filled.

6a0c3a6b-1253-4c70-bd9d-f66e21579724.png
 
How do you open the popup? Why does it only show notes for the one client and not all the records in the table?
 
How do you open the popup? Why does it only show notes for the one client and not all the records in the table?

The popup opens from a command button on another client related continuous form. The macro contains a 'where' clause "ClientID=" & ClientID. That way only that client's records will display.

For the time being I have disabled edit mode on the popup and made it read only other than the hyperlink which will take it to the client details form for adding new messages. I would like for it to be able to edit the messages table more quickly using the popup directly.

These forms are used in a very busy and dynamic environment, so being able to view and edit messages without having to switch between forms is desirable. The popup resides on top when open, but does not obscure much of the screen, and refreshes with each new client's messages when a new "client's message" button is selected, so would be the ideal way to deal with messages if it could work as desired.
 
This would not be that hard with VBA. Do you know any VBA? I can't find a way with macros to pass OpenArgs to the form, but in VBA we can do this . . .
Code:
    DoCmd.OpenForm "FormName", , , , , , Me.ClientID
If we can pass in the ClientID when the form opens, then we can set the DefaultValue property of the ClientID control, and if we set the filter at the same time, like this . . .
Code:
Private Sub Form_Load()
    If IsNumeric(Me.OpenArgs) Then
[COLOR="Green"]        'here we set the filter, and turn it on[/COLOR]
        Me.Filter = "ClientID = " & Me.OpenArgs
        Me.FilterOn = True
[COLOR="Green"]        'here we set the default value of the control[/COLOR]
        Me.ClientID.DefaultValue = Chr(34) & Me.OpenArgs & Chr(34)
    End If
End Sub
Something along those lines would solve your problem. Does that make sense?
 
This would not be that hard with VBA. Do you know any VBA? I can't find a way with macros to pass OpenArgs to the form, but in VBA we can do this . . .
Code:
    DoCmd.OpenForm "FormName", , , , , , Me.ClientID
If we can pass in the ClientID when the form opens, then we can set the DefaultValue property of the ClientID control, and if we set the filter at the same time, like this . . .
Code:
Private Sub Form_Load()
    If IsNumeric(Me.OpenArgs) Then
[COLOR=green]       'here we set the filter, and turn it on[/COLOR]
        Me.Filter = "ClientID = " & Me.OpenArgs
        Me.FilterOn = True
[COLOR=green]       'here we set the default value of the control[/COLOR]
        Me.ClientID.DefaultValue = Chr(34) & Me.OpenArgs & Chr(34)
    End If
End Sub
Something along those lines would solve your problem. Does that make sense?

I have used VBA for some things but I'm still very much a novice. I will try this and see if this works. I might need some more assistance with it though :o.
 
I tried the VBA but couldn't get it to work, so I found a work-around. I just made a new form with a hidden ClientID field behind a subform taking up the entire form area, and simply nominated the parent and child ID's as per normal, and hey presto! It works.

Thanks a heap anyway MarkK. I am going to take a course in VBA anyway, so I should be able to handle these things the 'right' way in the not-too-distant future.

Cheers and Happy New Year!
Steve.
 
That sounds like a good solution. Happy new year to you too.
 

Users who are viewing this thread

Back
Top Bottom