Help with forms

D

dk

I have 3 different forms ( frmclaimTechnical,
frmclaimMedical,frmClaimLegal). Each of them has subform (ordersChronology)
in datasheet wiew. The link between is ClaimID. Only one of those forms is
open depending of claim nature.

Id like to have button addNewOrder to open popup form NEW ORDER. After new
order is added i need to refresh data in subform ordersChronology.

I tried to use following code:
DoCmd.OpenForm NewOrder, , , stLinkCriteria, acFormEdit, acDialog

but I cant to figure out how to pass into new record value ClaimID.

Thank You for Your help!
 
D

dk

Reggie,
thank you for your time. Im preatty new in this matter.
Now, I put into the form frmclaimTechnical following code:
ClaimID field is Text/Unique/Indexed

Private Sub Command211_Click()
On Error GoTo Err_Command211_Click

Dim stDocName As String

stDocName = "NEWORDER"

DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog, Me.ClaimID

Exit_Command211_Click:
Me.Call_Listing_Subform.Requery
Exit Sub

Err_Command211_Click:
MsgBox Err.Description
Resume Exit_Command211_Click
End Sub

Into form NEWORDER I put following:
Private Sub Form_Open(Cancel As Integer)
Me.ClaimID = Me.OpenArgs
End Sub


I getting error message:
Run-time error "2448"
You cant assign a value to this object
In debug window of form NEWORDER I have following:
Me.ClaimID=Null
Me.OpenArgs= "0234u5" ( ClaimID value)
Where is the error ?!!
Once again thank You !
 
R

Reggie

dk, if the NEWORDER form is based on the same table that the form from where
you have your command button, this will not work because you will be trying
to add a new record with a duplicate key value as you have stated that
claimID is unique. However if you are opening a form with a different
(related) table that has the ClaimID as a foreign key then you need to first
set the focus to the control then set the value. When you are done adding
the record you can set the OnClose event of NEWORDER form to requery the
table that you are trying to requery.

Private Sub Form_Open(Cancel As Integer)
Me.ClaimID.Setfocus
Me.ClaimID = Me.OpenArgs
End Sub

Remove the requery event from here
Exit_Command211_Click:
Me.Call_Listing_Subform.Requery
Exit Sub

Add it to on close of the NEWORDER form. Change mainform name to name of
your main form
Private Sub Form_Close()
Forms![frmYourMainForm]![Call_Listing_Subform].Form.Requery
End Sub

Hope this helps.
 
D

dk

Reggie,
THNX, Your message helps a lot. Now Iam able to pass ClaimID value to form
NEWORDER, but..
The problem for me is that form NEWORDER ( is based on linked table) is
reachable from 3 different forms. If I put function OnExit You suggest, then
it works only with one of those forms (eg. Form1). How to recognise from
which form is NEWORDER form oppened (Form1 or Form2 or Form3)

Thank You for Your help,

DK

Reggie said:
dk, if the NEWORDER form is based on the same table that the form from where
you have your command button, this will not work because you will be trying
to add a new record with a duplicate key value as you have stated that
claimID is unique. However if you are opening a form with a different
(related) table that has the ClaimID as a foreign key then you need to first
set the focus to the control then set the value. When you are done adding
the record you can set the OnClose event of NEWORDER form to requery the
table that you are trying to requery.

Private Sub Form_Open(Cancel As Integer)
Me.ClaimID.Setfocus
Me.ClaimID = Me.OpenArgs
End Sub

Remove the requery event from here
Exit_Command211_Click:
Me.Call_Listing_Subform.Requery
Exit Sub

Add it to on close of the NEWORDER form. Change mainform name to name of
your main form
Private Sub Form_Close()
Forms![frmYourMainForm]![Call_Listing_Subform].Form.Requery
End Sub

Hope this helps.


--
Reggie

----------
dk said:
Reggie,
thank you for your time. Im preatty new in this matter.
Now, I put into the form frmclaimTechnical following code:
ClaimID field is Text/Unique/Indexed

Private Sub Command211_Click()
On Error GoTo Err_Command211_Click

Dim stDocName As String

stDocName = "NEWORDER"

DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog, Me.ClaimID

Exit_Command211_Click:
Me.Call_Listing_Subform.Requery
Exit Sub

Err_Command211_Click:
MsgBox Err.Description
Resume Exit_Command211_Click
End Sub

Into form NEWORDER I put following:
Private Sub Form_Open(Cancel As Integer)
Me.ClaimID = Me.OpenArgs
End Sub


I getting error message:
Run-time error "2448"
You cant assign a value to this object
In debug window of form NEWORDER I have following:
Me.ClaimID=Null
Me.OpenArgs= "0234u5" ( ClaimID value)
Where is the error ?!!
Once again thank You !

forms After
new
 
R

Reggie

dk, One way I do it is I have a standard module in my db's with the
following function in it. You could also place this in the NEWORDERS form
module, but placing it in a standard module allows you to use it from any
form in your app that may need it. Hope this helps!

'This function is in my basUtilities standard module
Public Function IsLoaded(ByVal strFormName As String) As Integer
Const CLOSED = 0
Const DESIGN = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> CLOSED Then
IsLoaded = True
End If
End Function

Now change your OnClose event to see which form is loaded. Something like:

Private Sub Form_Close()
On Error GoTo Err_Close

If IsLoaded("Form1") Then
Forms![Form1]![Call_Listing_Subform].Form.Requery
Exit Sub
ElseIf IsLoaded("Form2") Then
Forms![Form2]![Call_Listing_Subform].Form.Requery
Exit Sub
ElseIf IsLoaded("Form3") Then
Forms![Form3]![Call_Listing_Subform].Form.Requery
Exit Sub
End If

Exit_Close:
Exit Sub

Err_Close:
MsgBox Err.Description & Err.Number
Resume Exit_Close
End Sub

--
Reggie

----------
dk said:
Reggie,
THNX, Your message helps a lot. Now Iam able to pass ClaimID value to form
NEWORDER, but..
The problem for me is that form NEWORDER ( is based on linked table) is
reachable from 3 different forms. If I put function OnExit You suggest, then
it works only with one of those forms (eg. Form1). How to recognise from
which form is NEWORDER form oppened (Form1 or Form2 or Form3)

Thank You for Your help,

DK

Reggie said:
dk, if the NEWORDER form is based on the same table that the form from where
you have your command button, this will not work because you will be trying
to add a new record with a duplicate key value as you have stated that
claimID is unique. However if you are opening a form with a different
(related) table that has the ClaimID as a foreign key then you need to first
set the focus to the control then set the value. When you are done adding
the record you can set the OnClose event of NEWORDER form to requery the
table that you are trying to requery.

Private Sub Form_Open(Cancel As Integer)
Me.ClaimID.Setfocus
Me.ClaimID = Me.OpenArgs
End Sub

Remove the requery event from here
Exit_Command211_Click:
Me.Call_Listing_Subform.Requery
Exit Sub

Add it to on close of the NEWORDER form. Change mainform name to name of
your main form
Private Sub Form_Close()
Forms![frmYourMainForm]![Call_Listing_Subform].Form.Requery
End Sub

Hope this helps.


--
Reggie

----------
dk said:
Reggie,
thank you for your time. Im preatty new in this matter.
Now, I put into the form frmclaimTechnical following code:
ClaimID field is Text/Unique/Indexed

Private Sub Command211_Click()
On Error GoTo Err_Command211_Click

Dim stDocName As String

stDocName = "NEWORDER"

DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog, Me.ClaimID

Exit_Command211_Click:
Me.Call_Listing_Subform.Requery
Exit Sub

Err_Command211_Click:
MsgBox Err.Description
Resume Exit_Command211_Click
End Sub

Into form NEWORDER I put following:
Private Sub Form_Open(Cancel As Integer)
Me.ClaimID = Me.OpenArgs
End Sub


I getting error message:
Run-time error "2448"
You cant assign a value to this object
In debug window of form NEWORDER I have following:
Me.ClaimID=Null
Me.OpenArgs= "0234u5" ( ClaimID value)
Where is the error ?!!
Once again thank You !

dk, Lookup OpenArgs in the help file. If that don't help post back!

--
Reggie

----------
I have 3 different forms ( frmclaimTechnical,
frmclaimMedical,frmClaimLegal). Each of them has subform
(ordersChronology)
in datasheet wiew. The link between is ClaimID. Only one of those forms
is
open depending of claim nature.

Id like to have button addNewOrder to open popup form NEW ORDER. After
new
order is added i need to refresh data in subform ordersChronology.

I tried to use following code:
DoCmd.OpenForm NewOrder, , , stLinkCriteria, acFormEdit, acDialog

but I cant to figure out how to pass into new record value ClaimID.

Thank You for Your help!
 
D

dk

THANK YOU !
It works perfect !

dk

Reggie said:
dk, One way I do it is I have a standard module in my db's with the
following function in it. You could also place this in the NEWORDERS form
module, but placing it in a standard module allows you to use it from any
form in your app that may need it. Hope this helps!

'This function is in my basUtilities standard module
Public Function IsLoaded(ByVal strFormName As String) As Integer
Const CLOSED = 0
Const DESIGN = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> CLOSED Then
IsLoaded = True
End If
End Function

Now change your OnClose event to see which form is loaded. Something like:

Private Sub Form_Close()
On Error GoTo Err_Close

If IsLoaded("Form1") Then
Forms![Form1]![Call_Listing_Subform].Form.Requery
Exit Sub
ElseIf IsLoaded("Form2") Then
Forms![Form2]![Call_Listing_Subform].Form.Requery
Exit Sub
ElseIf IsLoaded("Form3") Then
Forms![Form3]![Call_Listing_Subform].Form.Requery
Exit Sub
End If

Exit_Close:
Exit Sub

Err_Close:
MsgBox Err.Description & Err.Number
Resume Exit_Close
End Sub

--
Reggie

----------
dk said:
Reggie,
THNX, Your message helps a lot. Now Iam able to pass ClaimID value to form
NEWORDER, but..
The problem for me is that form NEWORDER ( is based on linked table) is
reachable from 3 different forms. If I put function OnExit You suggest, then
it works only with one of those forms (eg. Form1). How to recognise from
which form is NEWORDER form oppened (Form1 or Form2 or Form3)

Thank You for Your help,

DK

Reggie said:
dk, if the NEWORDER form is based on the same table that the form from where
you have your command button, this will not work because you will be trying
to add a new record with a duplicate key value as you have stated that
claimID is unique. However if you are opening a form with a different
(related) table that has the ClaimID as a foreign key then you need to first
set the focus to the control then set the value. When you are done adding
the record you can set the OnClose event of NEWORDER form to requery the
table that you are trying to requery.

Private Sub Form_Open(Cancel As Integer)
Me.ClaimID.Setfocus
Me.ClaimID = Me.OpenArgs
End Sub

Remove the requery event from here
Exit_Command211_Click:
Me.Call_Listing_Subform.Requery
Exit Sub

Add it to on close of the NEWORDER form. Change mainform name to name of
your main form
Private Sub Form_Close()
Forms![frmYourMainForm]![Call_Listing_Subform].Form.Requery
End Sub

Hope this helps.


--
Reggie

----------
Reggie,
thank you for your time. Im preatty new in this matter.
Now, I put into the form frmclaimTechnical following code:
ClaimID field is Text/Unique/Indexed

Private Sub Command211_Click()
On Error GoTo Err_Command211_Click

Dim stDocName As String

stDocName = "NEWORDER"

DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog, Me.ClaimID

Exit_Command211_Click:
Me.Call_Listing_Subform.Requery
Exit Sub

Err_Command211_Click:
MsgBox Err.Description
Resume Exit_Command211_Click
End Sub

Into form NEWORDER I put following:
Private Sub Form_Open(Cancel As Integer)
Me.ClaimID = Me.OpenArgs
End Sub


I getting error message:
Run-time error "2448"
You cant assign a value to this object
In debug window of form NEWORDER I have following:
Me.ClaimID=Null
Me.OpenArgs= "0234u5" ( ClaimID value)
Where is the error ?!!
Once again thank You !

dk, Lookup OpenArgs in the help file. If that don't help post back!

--
Reggie

----------
I have 3 different forms ( frmclaimTechnical,
frmclaimMedical,frmClaimLegal). Each of them has subform
(ordersChronology)
in datasheet wiew. The link between is ClaimID. Only one of those
forms
is
open depending of claim nature.

Id like to have button addNewOrder to open popup form NEW ORDER. After
new
order is added i need to refresh data in subform ordersChronology.

I tried to use following code:
DoCmd.OpenForm NewOrder, , , stLinkCriteria, acFormEdit, acDialog

but I cant to figure out how to pass into new record value ClaimID.

Thank You for Your help!
 
R

Reggie

Your welcome!

--
Reggie

----------
dk said:
THANK YOU !
It works perfect !

dk

Reggie said:
dk, One way I do it is I have a standard module in my db's with the
following function in it. You could also place this in the NEWORDERS form
module, but placing it in a standard module allows you to use it from any
form in your app that may need it. Hope this helps!

'This function is in my basUtilities standard module
Public Function IsLoaded(ByVal strFormName As String) As Integer
Const CLOSED = 0
Const DESIGN = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> CLOSED Then
IsLoaded = True
End If
End Function

Now change your OnClose event to see which form is loaded. Something like:

Private Sub Form_Close()
On Error GoTo Err_Close

If IsLoaded("Form1") Then
Forms![Form1]![Call_Listing_Subform].Form.Requery
Exit Sub
ElseIf IsLoaded("Form2") Then
Forms![Form2]![Call_Listing_Subform].Form.Requery
Exit Sub
ElseIf IsLoaded("Form3") Then
Forms![Form3]![Call_Listing_Subform].Form.Requery
Exit Sub
End If

Exit_Close:
Exit Sub

Err_Close:
MsgBox Err.Description & Err.Number
Resume Exit_Close
End Sub

--
Reggie

----------
dk said:
Reggie,
THNX, Your message helps a lot. Now Iam able to pass ClaimID value to form
NEWORDER, but..
The problem for me is that form NEWORDER ( is based on linked table) is
reachable from 3 different forms. If I put function OnExit You
suggest,
then
it works only with one of those forms (eg. Form1). How to recognise from
which form is NEWORDER form oppened (Form1 or Form2 or Form3)

Thank You for Your help,

DK

dk, if the NEWORDER form is based on the same table that the form from
where
you have your command button, this will not work because you will be
trying
to add a new record with a duplicate key value as you have stated that
claimID is unique. However if you are opening a form with a different
(related) table that has the ClaimID as a foreign key then you need to
first
set the focus to the control then set the value. When you are done adding
the record you can set the OnClose event of NEWORDER form to requery the
table that you are trying to requery.

Private Sub Form_Open(Cancel As Integer)
Me.ClaimID.Setfocus
Me.ClaimID = Me.OpenArgs
End Sub

Remove the requery event from here
Exit_Command211_Click:
Me.Call_Listing_Subform.Requery
Exit Sub

Add it to on close of the NEWORDER form. Change mainform name to
name
of
your main form
Private Sub Form_Close()
Forms![frmYourMainForm]![Call_Listing_Subform].Form.Requery
End Sub

Hope this helps.


--
Reggie

----------
Reggie,
thank you for your time. Im preatty new in this matter.
Now, I put into the form frmclaimTechnical following code:
ClaimID field is Text/Unique/Indexed

Private Sub Command211_Click()
On Error GoTo Err_Command211_Click

Dim stDocName As String

stDocName = "NEWORDER"

DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog, Me.ClaimID

Exit_Command211_Click:
Me.Call_Listing_Subform.Requery
Exit Sub

Err_Command211_Click:
MsgBox Err.Description
Resume Exit_Command211_Click
End Sub

Into form NEWORDER I put following:
Private Sub Form_Open(Cancel As Integer)
Me.ClaimID = Me.OpenArgs
End Sub


I getting error message:
Run-time error "2448"
You cant assign a value to this object
In debug window of form NEWORDER I have following:
Me.ClaimID=Null
Me.OpenArgs= "0234u5" ( ClaimID value)
Where is the error ?!!
Once again thank You !

dk, Lookup OpenArgs in the help file. If that don't help post back!

--
Reggie

----------
I have 3 different forms ( frmclaimTechnical,
frmclaimMedical,frmClaimLegal). Each of them has subform
(ordersChronology)
in datasheet wiew. The link between is ClaimID. Only one of those
forms
is
open depending of claim nature.

Id like to have button addNewOrder to open popup form NEW ORDER.
After
new
order is added i need to refresh data in subform ordersChronology.

I tried to use following code:
DoCmd.OpenForm NewOrder, , , stLinkCriteria, acFormEdit,
acDialog

but I cant to figure out how to pass into new record value ClaimID.

Thank You for Your help!
 

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