From: Joe on
Ok...

Let me see what the best way to say this. I have a Clients table and a
Services table. on my Clients form I need to add a command button to open my
Services form but the ID from the my Clients table does not appear on my
Services table. The forms link perfectly if the ID already exists on the
Clients table. However, when I enter a new client and try to open the
services form the Client ID does not appear on my Services form.

CLI_ID PK on Clients, SER_ID PK on Services and CLI_ID SK on Services. Any
suggestions or ideas would be helpful.
From: Arvin Meyer [MVP] on
"Joe" <Joe(a)discussions.microsoft.com> wrote in message
news:B5BD3A1C-B31F-4DF3-B2D9-B4C6AE2292E5(a)microsoft.com...
> Ok...
>
> Let me see what the best way to say this. I have a Clients table and a
> Services table. on my Clients form I need to add a command button to open
> my
> Services form but the ID from the my Clients table does not appear on my
> Services table. The forms link perfectly if the ID already exists on the
> Clients table. However, when I enter a new client and try to open the
> services form the Client ID does not appear on my Services form.
>
> CLI_ID PK on Clients, SER_ID PK on Services and CLI_ID SK on Services.
> Any
> suggestions or ideas would be helpful.

So what you need to do is to first save the record, then open using the
record. There will be a blank record in the Services form. Set the
DefaultValue property of the ClientID textbox in the Services form to:

=Forms!FormNameForClients!ClientID

Now you should be able to sync them at the next opening.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


From: Joe on
Hello Arvin,

I try that and the client id does not appear on the services form after its
saved. I'm working around it by having the Services form as a subform on the
clients table. I didn't want that because the Services table needs a subform
for ServicesDescriptions.

"Arvin Meyer [MVP]" wrote:

> "Joe" <Joe(a)discussions.microsoft.com> wrote in message
> news:B5BD3A1C-B31F-4DF3-B2D9-B4C6AE2292E5(a)microsoft.com...
> > Ok...
> >
> > Let me see what the best way to say this. I have a Clients table and a
> > Services table. on my Clients form I need to add a command button to open
> > my
> > Services form but the ID from the my Clients table does not appear on my
> > Services table. The forms link perfectly if the ID already exists on the
> > Clients table. However, when I enter a new client and try to open the
> > services form the Client ID does not appear on my Services form.
> >
> > CLI_ID PK on Clients, SER_ID PK on Services and CLI_ID SK on Services.
> > Any
> > suggestions or ideas would be helpful.
>
> So what you need to do is to first save the record, then open using the
> record. There will be a blank record in the Services form. Set the
> DefaultValue property of the ClientID textbox in the Services form to:
>
> =Forms!FormNameForClients!ClientID
>
> Now you should be able to sync them at the next opening.
> --
> Arvin Meyer, MCP, MVP
> http://www.datastrat.com
> http://www.mvps.org/access
> http://www.accessmvp.com
>
>
> .
>
From: John W. Vinson on
On Fri, 22 Jan 2010 13:45:02 -0800, Joe <Joe(a)discussions.microsoft.com> wrote:

> I didn't want that because the Services table needs a subform
>for ServicesDescriptions.

Why?

Do be aware that you can use a Query joining Services to ServicesDescriptions.
Properly handled it would be updateable (unless each service has multiple
descriptions).
--

John W. Vinson [MVP]
From: KenSheridan via AccessMonster.com on
If opening a 'linked' form in this way I usually prefer to open it in
dialogue mode as this forces the user to close it before returning to the
first form. For this the code to open the services form would be like this:

' ensure current record is saved
Me.Dirty = False
' open services form, passing current CLI_ID
' value to it as its OpenArgs property
DoCmd.OpenForm "frmServices", _
WhereCondition:= "CLI_ID = " & Me.CLI_ID, _
WindowMode:=acDialog, _
OpenArgs:= Me.CLI_ID
' ensure frmServices is closed
DoCmd.Close acForm "frmServices"

Then in frmServices' Open event procedure set the DefaultValue property of
the CLI_ID control with:

If Not IsNull(Me.OpenArgs) Then
Me.CLI_ID.DefaultValue = """" & Me.OpenArgs & """"
End If

Note that the DefaultValue property is always a string expression, so
regardless of the data type of the field in question, should be wrapped in
literal quotes characters as above. This is not always essential on fact,
but can be so in some situations where you might not expect it to be, so the
quotes characters should always be included. You must have a control CLI_ID
on frmServices, bound to the underlying CLI_ID field for this to work, but
the control can be hidden if wished.

If you want to be able to move focus between both forms rather than having
the second opened in dialogue mode, remove the following lines from the
calling procedure:

WindowMode:=acDialog, _

and:

' ensure frmServices is closed
DoCmd.Close acForm "frmServices"

The reason for the latter BTW is that if a form in dialogue mode is hidden
rather than closed this also resumes code execution in the calling procedure,
so to cater for this remote possibility its as well to close the form
explicitly as above. No error is raised if it has already been closed.

You should also then add the following lines to frmServices' Current event
procedure to keep it in sync with the clients form:

On Error Resume Next
Me.Filter = "CLI_ID = " & Nz(Forms("frmClients").CLI_ID,0)
Me.CLI_ID.DefaultValue = """" & Forms("frmClients").CLI_ID & """"

Ken Sheridan
Stafford, England

Joe wrote:
>Hello Arvin,
>
>I try that and the client id does not appear on the services form after its
>saved. I'm working around it by having the Services form as a subform on the
>clients table. I didn't want that because the Services table needs a subform
>for ServicesDescriptions.
>
>> > Ok...
>> >
>[quoted text clipped - 17 lines]
>>
>> Now you should be able to sync them at the next opening.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access/201001/1

 |  Next  |  Last
Pages: 1 2
Prev: Front End User Interface Help
Next: acFormat XLS