Issure wiht subforms and command button

M

Michelle

I have a main from called Equipment it has 2 subforms one for the IP Data and
one for Budget Data.
When I cleck the command button it opens the sub form however it does not
seem to copy the IDTag to the subfrom IDTag area so that everything is linked
together right.
My Tables are:
tblEquipment
IDTag - Txt & PK
EquipmentType
Location
LocationDesc
Mfg
Model
SerialNum
PONum
Contract
WarType
WarExpDate
Surplus
SurplusDate
InventoryDate
Notes

tblBudgeting
ID - Auto # & PK
IDTag
BdgYear
Expenditure
Purpose

tblIPData
ID -Auto # & PK
EIDTag
MAC
IP
SN
GW
PDNS
SDNS
Wireless

Relationships are:
tblEquipment to tblBudgeting on IDTag = IDTag One-To-Many all from
tblEquipment and only those from tblBudgeting where fields are equal.
tblEquipment to tblIPData on IDTag = EIDTag One-To-Many all from
tblEquipment and only those from tblIPData where fields are equal.

Here is my code for the command buttons:
IPData
Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmIPData!EIDTag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

Budget
Private Sub Budget_Click()
On Error GoTo Err_Budget_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBudget"

stLinkCriteria = "[IDTag]=" & Me![ID]
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmbudget!IDTag.DefaultValue = Me.ID
DoCmd.MoveSize 3 * 1440, 2 * 1440, 5.4 * 1440, 7 * 1440

Exit_Budget_Click:
Exit Sub

Err_Budget_Click:
MsgBox Err.Description
Resume Exit_Budget_Click


End Sub
 
J

Jeanette Cunningham

Michelle,
use a different approach - the usual way is to set up the main form with one
subform.
Access will automatically create the link Master and Child fields for you,
or you can edit them yourself.
After you have a form and subform setup, you can change the source object
that goes inside the subform.
Your command button would change which form shows inside the subform control
something like this:

command button to show budgets
Me.SubformControlName.SourceObject = "sfrmBudgeting"

command button to show ip data
Me.SubformControlName.SourceObject = "sfrmIPData"

Note that the subform sits inside the subform control. The subform can have
a different name from the subform control.

Jeanette Cunningham
 
M

Michelle

I am not sure I understand your code or what your trying to have me do. I
would like to know if this will or will not work at all. I have it working
in another database the only difference is that in the other database the
field is a number not text.

Jeanette Cunningham said:
Michelle,
use a different approach - the usual way is to set up the main form with one
subform.
Access will automatically create the link Master and Child fields for you,
or you can edit them yourself.
After you have a form and subform setup, you can change the source object
that goes inside the subform.
Your command button would change which form shows inside the subform control
something like this:

command button to show budgets
Me.SubformControlName.SourceObject = "sfrmBudgeting"

command button to show ip data
Me.SubformControlName.SourceObject = "sfrmIPData"

Note that the subform sits inside the subform control. The subform can have
a different name from the subform control.

Jeanette Cunningham



Michelle said:
I have a main from called Equipment it has 2 subforms one for the IP Data
and
one for Budget Data.
When I cleck the command button it opens the sub form however it does not
seem to copy the IDTag to the subfrom IDTag area so that everything is
linked
together right.
My Tables are:
tblEquipment
IDTag - Txt & PK
EquipmentType
Location
LocationDesc
Mfg
Model
SerialNum
PONum
Contract
WarType
WarExpDate
Surplus
SurplusDate
InventoryDate
Notes

tblBudgeting
ID - Auto # & PK
IDTag
BdgYear
Expenditure
Purpose

tblIPData
ID -Auto # & PK
EIDTag
MAC
IP
SN
GW
PDNS
SDNS
Wireless

Relationships are:
tblEquipment to tblBudgeting on IDTag = IDTag One-To-Many all from
tblEquipment and only those from tblBudgeting where fields are equal.
tblEquipment to tblIPData on IDTag = EIDTag One-To-Many all from
tblEquipment and only those from tblIPData where fields are equal.

Here is my code for the command buttons:
IPData
Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmIPData!EIDTag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

Budget
Private Sub Budget_Click()
On Error GoTo Err_Budget_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBudget"

stLinkCriteria = "[IDTag]=" & Me![ID]
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmbudget!IDTag.DefaultValue = Me.ID
DoCmd.MoveSize 3 * 1440, 2 * 1440, 5.4 * 1440, 7 * 1440

Exit_Budget_Click:
Exit Sub

Err_Budget_Click:
MsgBox Err.Description
Resume Exit_Budget_Click


End Sub
 
J

Jeanette Cunningham

Michelle,
in that case, change this line to:

stLinkCriteria = "[EIDTag]=" & Me![IDTag] & ""


Jeanette Cunningham


Michelle said:
I am not sure I understand your code or what your trying to have me do. I
would like to know if this will or will not work at all. I have it
working
in another database the only difference is that in the other database the
field is a number not text.

Jeanette Cunningham said:
Michelle,
use a different approach - the usual way is to set up the main form with
one
subform.
Access will automatically create the link Master and Child fields for
you,
or you can edit them yourself.
After you have a form and subform setup, you can change the source object
that goes inside the subform.
Your command button would change which form shows inside the subform
control
something like this:

command button to show budgets
Me.SubformControlName.SourceObject = "sfrmBudgeting"

command button to show ip data
Me.SubformControlName.SourceObject = "sfrmIPData"

Note that the subform sits inside the subform control. The subform can
have
a different name from the subform control.

Jeanette Cunningham



Michelle said:
I have a main from called Equipment it has 2 subforms one for the IP
Data
and
one for Budget Data.
When I cleck the command button it opens the sub form however it does
not
seem to copy the IDTag to the subfrom IDTag area so that everything is
linked
together right.
My Tables are:
tblEquipment
IDTag - Txt & PK
EquipmentType
Location
LocationDesc
Mfg
Model
SerialNum
PONum
Contract
WarType
WarExpDate
Surplus
SurplusDate
InventoryDate
Notes

tblBudgeting
ID - Auto # & PK
IDTag
BdgYear
Expenditure
Purpose

tblIPData
ID -Auto # & PK
EIDTag
MAC
IP
SN
GW
PDNS
SDNS
Wireless

Relationships are:
tblEquipment to tblBudgeting on IDTag = IDTag One-To-Many all from
tblEquipment and only those from tblBudgeting where fields are equal.
tblEquipment to tblIPData on IDTag = EIDTag One-To-Many all from
tblEquipment and only those from tblIPData where fields are equal.

Here is my code for the command buttons:
IPData
Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmIPData!EIDTag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

Budget
Private Sub Budget_Click()
On Error GoTo Err_Budget_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBudget"

stLinkCriteria = "[IDTag]=" & Me![ID]
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmbudget!IDTag.DefaultValue = Me.ID
DoCmd.MoveSize 3 * 1440, 2 * 1440, 5.4 * 1440, 7 * 1440

Exit_Budget_Click:
Exit Sub

Err_Budget_Click:
MsgBox Err.Description
Resume Exit_Budget_Click


End Sub
 
M

Michelle

That gives me thie following Error:

The expression On Click you entered as the event property setting produced
the following error: Ambigous name detected: Budget_Click
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.
This error occurs when an event has failed to run because Microsoft Office
Access cannot evaluate the location of the logic for the event. For example,
if the OnOpen property of a form is set to =[Field], this error occurs
because Access expects a macro or event name to run when the event is fired.


Jeanette Cunningham said:
Michelle,
in that case, change this line to:

stLinkCriteria = "[EIDTag]=" & Me![IDTag] & ""


Jeanette Cunningham


Michelle said:
I am not sure I understand your code or what your trying to have me do. I
would like to know if this will or will not work at all. I have it
working
in another database the only difference is that in the other database the
field is a number not text.

Jeanette Cunningham said:
Michelle,
use a different approach - the usual way is to set up the main form with
one
subform.
Access will automatically create the link Master and Child fields for
you,
or you can edit them yourself.
After you have a form and subform setup, you can change the source object
that goes inside the subform.
Your command button would change which form shows inside the subform
control
something like this:

command button to show budgets
Me.SubformControlName.SourceObject = "sfrmBudgeting"

command button to show ip data
Me.SubformControlName.SourceObject = "sfrmIPData"

Note that the subform sits inside the subform control. The subform can
have
a different name from the subform control.

Jeanette Cunningham



I have a main from called Equipment it has 2 subforms one for the IP
Data
and
one for Budget Data.
When I cleck the command button it opens the sub form however it does
not
seem to copy the IDTag to the subfrom IDTag area so that everything is
linked
together right.
My Tables are:
tblEquipment
IDTag - Txt & PK
EquipmentType
Location
LocationDesc
Mfg
Model
SerialNum
PONum
Contract
WarType
WarExpDate
Surplus
SurplusDate
InventoryDate
Notes

tblBudgeting
ID - Auto # & PK
IDTag
BdgYear
Expenditure
Purpose

tblIPData
ID -Auto # & PK
EIDTag
MAC
IP
SN
GW
PDNS
SDNS
Wireless

Relationships are:
tblEquipment to tblBudgeting on IDTag = IDTag One-To-Many all from
tblEquipment and only those from tblBudgeting where fields are equal.
tblEquipment to tblIPData on IDTag = EIDTag One-To-Many all from
tblEquipment and only those from tblIPData where fields are equal.

Here is my code for the command buttons:
IPData
Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmIPData!EIDTag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

Budget
Private Sub Budget_Click()
On Error GoTo Err_Budget_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBudget"

stLinkCriteria = "[IDTag]=" & Me![ID]
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmbudget!IDTag.DefaultValue = Me.ID
DoCmd.MoveSize 3 * 1440, 2 * 1440, 5.4 * 1440, 7 * 1440

Exit_Budget_Click:
Exit Sub

Err_Budget_Click:
MsgBox Err.Description
Resume Exit_Budget_Click


End Sub
 
J

Jeanette Cunningham

Michelle,
this error: 'Ambigous name detected: Budget_Click', usually means that you
have 2 different routines both called Budget_Click.
Find the other Budget_Click code and comment it out. Now run the form and
see if it works.


Jeanette Cunningham


Michelle said:
That gives me thie following Error:

The expression On Click you entered as the event property setting produced
the following error: Ambigous name detected: Budget_Click
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.
This error occurs when an event has failed to run because Microsoft Office
Access cannot evaluate the location of the logic for the event. For
example,
if the OnOpen property of a form is set to =[Field], this error occurs
because Access expects a macro or event name to run when the event is
fired.


Jeanette Cunningham said:
Michelle,
in that case, change this line to:

stLinkCriteria = "[EIDTag]=" & Me![IDTag] & ""


Jeanette Cunningham


Michelle said:
I am not sure I understand your code or what your trying to have me do.
I
would like to know if this will or will not work at all. I have it
working
in another database the only difference is that in the other database
the
field is a number not text.

:

Michelle,
use a different approach - the usual way is to set up the main form
with
one
subform.
Access will automatically create the link Master and Child fields for
you,
or you can edit them yourself.
After you have a form and subform setup, you can change the source
object
that goes inside the subform.
Your command button would change which form shows inside the subform
control
something like this:

command button to show budgets
Me.SubformControlName.SourceObject = "sfrmBudgeting"

command button to show ip data
Me.SubformControlName.SourceObject = "sfrmIPData"

Note that the subform sits inside the subform control. The subform can
have
a different name from the subform control.

Jeanette Cunningham



I have a main from called Equipment it has 2 subforms one for the IP
Data
and
one for Budget Data.
When I cleck the command button it opens the sub form however it
does
not
seem to copy the IDTag to the subfrom IDTag area so that everything
is
linked
together right.
My Tables are:
tblEquipment
IDTag - Txt & PK
EquipmentType
Location
LocationDesc
Mfg
Model
SerialNum
PONum
Contract
WarType
WarExpDate
Surplus
SurplusDate
InventoryDate
Notes

tblBudgeting
ID - Auto # & PK
IDTag
BdgYear
Expenditure
Purpose

tblIPData
ID -Auto # & PK
EIDTag
MAC
IP
SN
GW
PDNS
SDNS
Wireless

Relationships are:
tblEquipment to tblBudgeting on IDTag = IDTag One-To-Many all from
tblEquipment and only those from tblBudgeting where fields are
equal.
tblEquipment to tblIPData on IDTag = EIDTag One-To-Many all from
tblEquipment and only those from tblIPData where fields are equal.

Here is my code for the command buttons:
IPData
Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmIPData!EIDTag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

Budget
Private Sub Budget_Click()
On Error GoTo Err_Budget_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBudget"

stLinkCriteria = "[IDTag]=" & Me![ID]
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmbudget!IDTag.DefaultValue = Me.ID
DoCmd.MoveSize 3 * 1440, 2 * 1440, 5.4 * 1440, 7 * 1440

Exit_Budget_Click:
Exit Sub

Err_Budget_Click:
MsgBox Err.Description
Resume Exit_Budget_Click


End Sub
 
J

Jeanette Cunningham

Michelle,
where is the button called CancelUser?
Is it the line 'If (Me.Dirty = True) Then Me.Dirty = False
that causes the error?

Here are 2 suggestions about how you set out your code.
They won't fix the error, but are suggestions to make your code easier to
read and debug.

I suggest that you write your If statements on 3 lines - this makes it
easier to read and debug your code when you are learning how to use access.

Another suggestion:
Docmd.Close is better used like this:

DoCmd.Close acForm, Me.Name

Or
DoCmd.Close acForm, "NameOfForm"

If you don't specify what to close, access has to guess.
Your code is easier to read and understand if you are specific about what is
being closed.

Jeanette Cunningham


Michelle said:
That fixed that error now I get an error that says:
Syntax error (missing operator) in query expression'[EquipmentID]=12KZ791'
the 12KZ791 is the IDTag for the piece of equipment on the screen at this
time.
Here is my code:

Private Sub CancelUser_Click()
On Error GoTo Err_CancelUser_Click


If Me.Dirty Then Me.Dirty = False
DoCmd.Close

Exit_CancelUser_Click:
Exit Sub

Err_CancelUser_Click:
MsgBox Err.Description
Resume Exit_CancelUser_Click

End Sub


Jeanette Cunningham said:
Michelle,
this error: 'Ambigous name detected: Budget_Click', usually means that
you
have 2 different routines both called Budget_Click.
Find the other Budget_Click code and comment it out. Now run the form and
see if it works.


Jeanette Cunningham


Michelle said:
That gives me thie following Error:

The expression On Click you entered as the event property setting
produced
the following error: Ambigous name detected: Budget_Click
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.
This error occurs when an event has failed to run because Microsoft
Office
Access cannot evaluate the location of the logic for the event. For
example,
if the OnOpen property of a form is set to =[Field], this error occurs
because Access expects a macro or event name to run when the event is
fired.


:

Michelle,
in that case, change this line to:

stLinkCriteria = "[EIDTag]=" & Me![IDTag] & ""


Jeanette Cunningham


I am not sure I understand your code or what your trying to have me
do.
I
would like to know if this will or will not work at all. I have it
working
in another database the only difference is that in the other
database
the
field is a number not text.

:

Michelle,
use a different approach - the usual way is to set up the main form
with
one
subform.
Access will automatically create the link Master and Child fields
for
you,
or you can edit them yourself.
After you have a form and subform setup, you can change the source
object
that goes inside the subform.
Your command button would change which form shows inside the
subform
control
something like this:

command button to show budgets
Me.SubformControlName.SourceObject = "sfrmBudgeting"

command button to show ip data
Me.SubformControlName.SourceObject = "sfrmIPData"

Note that the subform sits inside the subform control. The subform
can
have
a different name from the subform control.

Jeanette Cunningham



I have a main from called Equipment it has 2 subforms one for the
IP
Data
and
one for Budget Data.
When I cleck the command button it opens the sub form however it
does
not
seem to copy the IDTag to the subfrom IDTag area so that
everything
is
linked
together right.
My Tables are:
tblEquipment
IDTag - Txt & PK
EquipmentType
Location
LocationDesc
Mfg
Model
SerialNum
PONum
Contract
WarType
WarExpDate
Surplus
SurplusDate
InventoryDate
Notes

tblBudgeting
ID - Auto # & PK
IDTag
BdgYear
Expenditure
Purpose

tblIPData
ID -Auto # & PK
EIDTag
MAC
IP
SN
GW
PDNS
SDNS
Wireless

Relationships are:
tblEquipment to tblBudgeting on IDTag = IDTag One-To-Many all
from
tblEquipment and only those from tblBudgeting where fields are
equal.
tblEquipment to tblIPData on IDTag = EIDTag One-To-Many all from
tblEquipment and only those from tblIPData where fields are
equal.

Here is my code for the command buttons:
IPData
Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmIPData!EIDTag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

Budget
Private Sub Budget_Click()
On Error GoTo Err_Budget_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBudget"

stLinkCriteria = "[IDTag]=" & Me![ID]
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmbudget!IDTag.DefaultValue = Me.ID
DoCmd.MoveSize 3 * 1440, 2 * 1440, 5.4 * 1440, 7 * 1440

Exit_Budget_Click:
Exit Sub

Err_Budget_Click:
MsgBox Err.Description
Resume Exit_Budget_Click


End Sub
 
M

Michelle

I am so sorry...I copied the wrong code....

Private Sub Budget_Click()
On Error GoTo Err_Budget_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBudget"

stLinkCriteria = "[EquipmentID]=" & Me![IDTag] & ""
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmbudget!EquipmentID.DefaultValue = Me.[IDTag]
DoCmd.MoveSize 3 * 1440, 2 * 1440, 5.4 * 1440, 7 * 1440

Exit_Budget_Click:
Exit Sub

Err_Budget_Click:
MsgBox Err.Description
Resume Exit_Budget_Click

End Sub
Jeanette Cunningham said:
Michelle,
where is the button called CancelUser?
Is it the line 'If (Me.Dirty = True) Then Me.Dirty = False
that causes the error?

Here are 2 suggestions about how you set out your code.
They won't fix the error, but are suggestions to make your code easier to
read and debug.

I suggest that you write your If statements on 3 lines - this makes it
easier to read and debug your code when you are learning how to use access.

Another suggestion:
Docmd.Close is better used like this:

DoCmd.Close acForm, Me.Name

Or
DoCmd.Close acForm, "NameOfForm"

If you don't specify what to close, access has to guess.
Your code is easier to read and understand if you are specific about what is
being closed.

Jeanette Cunningham


Michelle said:
That fixed that error now I get an error that says:
Syntax error (missing operator) in query expression'[EquipmentID]=12KZ791'
the 12KZ791 is the IDTag for the piece of equipment on the screen at this
time.
Here is my code:

Private Sub CancelUser_Click()
On Error GoTo Err_CancelUser_Click


If Me.Dirty Then Me.Dirty = False
DoCmd.Close

Exit_CancelUser_Click:
Exit Sub

Err_CancelUser_Click:
MsgBox Err.Description
Resume Exit_CancelUser_Click

End Sub


Jeanette Cunningham said:
Michelle,
this error: 'Ambigous name detected: Budget_Click', usually means that
you
have 2 different routines both called Budget_Click.
Find the other Budget_Click code and comment it out. Now run the form and
see if it works.


Jeanette Cunningham


That gives me thie following Error:

The expression On Click you entered as the event property setting
produced
the following error: Ambigous name detected: Budget_Click
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.
This error occurs when an event has failed to run because Microsoft
Office
Access cannot evaluate the location of the logic for the event. For
example,
if the OnOpen property of a form is set to =[Field], this error occurs
because Access expects a macro or event name to run when the event is
fired.


:

Michelle,
in that case, change this line to:

stLinkCriteria = "[EIDTag]=" & Me![IDTag] & ""


Jeanette Cunningham


I am not sure I understand your code or what your trying to have me
do.
I
would like to know if this will or will not work at all. I have it
working
in another database the only difference is that in the other
database
the
field is a number not text.

:

Michelle,
use a different approach - the usual way is to set up the main form
with
one
subform.
Access will automatically create the link Master and Child fields
for
you,
or you can edit them yourself.
After you have a form and subform setup, you can change the source
object
that goes inside the subform.
Your command button would change which form shows inside the
subform
control
something like this:

command button to show budgets
Me.SubformControlName.SourceObject = "sfrmBudgeting"

command button to show ip data
Me.SubformControlName.SourceObject = "sfrmIPData"

Note that the subform sits inside the subform control. The subform
can
have
a different name from the subform control.

Jeanette Cunningham



I have a main from called Equipment it has 2 subforms one for the
IP
Data
and
one for Budget Data.
When I cleck the command button it opens the sub form however it
does
not
seem to copy the IDTag to the subfrom IDTag area so that
everything
is
linked
together right.
My Tables are:
tblEquipment
IDTag - Txt & PK
EquipmentType
Location
LocationDesc
Mfg
Model
SerialNum
PONum
Contract
WarType
WarExpDate
Surplus
SurplusDate
InventoryDate
Notes

tblBudgeting
ID - Auto # & PK
IDTag
BdgYear
Expenditure
Purpose

tblIPData
ID -Auto # & PK
EIDTag
MAC
IP
SN
GW
PDNS
SDNS
Wireless

Relationships are:
tblEquipment to tblBudgeting on IDTag = IDTag One-To-Many all
from
tblEquipment and only those from tblBudgeting where fields are
equal.
tblEquipment to tblIPData on IDTag = EIDTag One-To-Many all from
tblEquipment and only those from tblIPData where fields are
equal.

Here is my code for the command buttons:
IPData
Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmIPData!EIDTag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

Budget
Private Sub Budget_Click()
On Error GoTo Err_Budget_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBudget"

stLinkCriteria = "[IDTag]=" & Me![ID]
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmbudget!IDTag.DefaultValue = Me.ID
DoCmd.MoveSize 3 * 1440, 2 * 1440, 5.4 * 1440, 7 * 1440

Exit_Budget_Click:
Exit Sub

Err_Budget_Click:
MsgBox Err.Description
Resume Exit_Budget_Click


End Sub
 
M

Michelle

I got rid of the error...however it is not pulling the EquipmentID into the
subform.
Here is an update of the code.

Private Sub Budget_Click()
On Error GoTo Err_Budget_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBudget"

stLinkCriteria = "[EquipmentID]='" & Me![IDTag] & "'"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmbudget!equipmentID.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 5.4 * 1440, 7 * 1440

Exit_Budget_Click:
Exit Sub

Err_Budget_Click:
MsgBox Err.Description
Resume Exit_Budget_Click

End Sub

Jeanette Cunningham said:
Michelle,
where is the button called CancelUser?
Is it the line 'If (Me.Dirty = True) Then Me.Dirty = False
that causes the error?

Here are 2 suggestions about how you set out your code.
They won't fix the error, but are suggestions to make your code easier to
read and debug.

I suggest that you write your If statements on 3 lines - this makes it
easier to read and debug your code when you are learning how to use access.

Another suggestion:
Docmd.Close is better used like this:

DoCmd.Close acForm, Me.Name

Or
DoCmd.Close acForm, "NameOfForm"

If you don't specify what to close, access has to guess.
Your code is easier to read and understand if you are specific about what is
being closed.

Jeanette Cunningham


Michelle said:
That fixed that error now I get an error that says:
Syntax error (missing operator) in query expression'[EquipmentID]=12KZ791'
the 12KZ791 is the IDTag for the piece of equipment on the screen at this
time.
Here is my code:

Private Sub CancelUser_Click()
On Error GoTo Err_CancelUser_Click


If Me.Dirty Then Me.Dirty = False
DoCmd.Close

Exit_CancelUser_Click:
Exit Sub

Err_CancelUser_Click:
MsgBox Err.Description
Resume Exit_CancelUser_Click

End Sub


Jeanette Cunningham said:
Michelle,
this error: 'Ambigous name detected: Budget_Click', usually means that
you
have 2 different routines both called Budget_Click.
Find the other Budget_Click code and comment it out. Now run the form and
see if it works.


Jeanette Cunningham


That gives me thie following Error:

The expression On Click you entered as the event property setting
produced
the following error: Ambigous name detected: Budget_Click
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.
This error occurs when an event has failed to run because Microsoft
Office
Access cannot evaluate the location of the logic for the event. For
example,
if the OnOpen property of a form is set to =[Field], this error occurs
because Access expects a macro or event name to run when the event is
fired.


:

Michelle,
in that case, change this line to:

stLinkCriteria = "[EIDTag]=" & Me![IDTag] & ""


Jeanette Cunningham


I am not sure I understand your code or what your trying to have me
do.
I
would like to know if this will or will not work at all. I have it
working
in another database the only difference is that in the other
database
the
field is a number not text.

:

Michelle,
use a different approach - the usual way is to set up the main form
with
one
subform.
Access will automatically create the link Master and Child fields
for
you,
or you can edit them yourself.
After you have a form and subform setup, you can change the source
object
that goes inside the subform.
Your command button would change which form shows inside the
subform
control
something like this:

command button to show budgets
Me.SubformControlName.SourceObject = "sfrmBudgeting"

command button to show ip data
Me.SubformControlName.SourceObject = "sfrmIPData"

Note that the subform sits inside the subform control. The subform
can
have
a different name from the subform control.

Jeanette Cunningham



I have a main from called Equipment it has 2 subforms one for the
IP
Data
and
one for Budget Data.
When I cleck the command button it opens the sub form however it
does
not
seem to copy the IDTag to the subfrom IDTag area so that
everything
is
linked
together right.
My Tables are:
tblEquipment
IDTag - Txt & PK
EquipmentType
Location
LocationDesc
Mfg
Model
SerialNum
PONum
Contract
WarType
WarExpDate
Surplus
SurplusDate
InventoryDate
Notes

tblBudgeting
ID - Auto # & PK
IDTag
BdgYear
Expenditure
Purpose

tblIPData
ID -Auto # & PK
EIDTag
MAC
IP
SN
GW
PDNS
SDNS
Wireless

Relationships are:
tblEquipment to tblBudgeting on IDTag = IDTag One-To-Many all
from
tblEquipment and only those from tblBudgeting where fields are
equal.
tblEquipment to tblIPData on IDTag = EIDTag One-To-Many all from
tblEquipment and only those from tblIPData where fields are
equal.

Here is my code for the command buttons:
IPData
Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmIPData!EIDTag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

Budget
Private Sub Budget_Click()
On Error GoTo Err_Budget_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBudget"

stLinkCriteria = "[IDTag]=" & Me![ID]
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmbudget!IDTag.DefaultValue = Me.ID
DoCmd.MoveSize 3 * 1440, 2 * 1440, 5.4 * 1440, 7 * 1440

Exit_Budget_Click:
Exit Sub

Err_Budget_Click:
MsgBox Err.Description
Resume Exit_Budget_Click


End Sub
 
J

Jeanette Cunningham

Michelle,
we seem to have gone a bit off track.
Here is the general idea for forms with subforms.

Create your main form and set up the 2 subforms on it.
Use the wizard to set up the subforms, and the Link Master fields and Child
fields will be set up automatically for you as you step through the wizard.

Use your button to open the budget form to make the subform visible or not
visible.
The code you have to open frmBudget is trying to open the form as a separate
form, not as a subform.

Once you have the link master and child fields set up correctly, you just
show or hide the subform with this code.
(delete your current code for opening frmBudget).

Private Sub Budget_Click()
Me.NameOfSubformControl.Visible = Not Me.NameOfSubformControl.Visible
End Sub

Add your error handling to the above code.
When the user clicks the Budget button, the budget form inside the subform
control will appear or disappear.
The button will act like a toggle that will show the subform if it is
hidden, or hide it if it is visible.


Jeanette Cunningham



Michelle said:
I got rid of the error...however it is not pulling the EquipmentID into the
subform.
Here is an update of the code.

Private Sub Budget_Click()
On Error GoTo Err_Budget_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBudget"

stLinkCriteria = "[EquipmentID]='" & Me![IDTag] & "'"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmbudget!equipmentID.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 5.4 * 1440, 7 * 1440

Exit_Budget_Click:
Exit Sub

Err_Budget_Click:
MsgBox Err.Description
Resume Exit_Budget_Click

End Sub

Jeanette Cunningham said:
Michelle,
where is the button called CancelUser?
Is it the line 'If (Me.Dirty = True) Then Me.Dirty = False
that causes the error?

Here are 2 suggestions about how you set out your code.
They won't fix the error, but are suggestions to make your code easier to
read and debug.

I suggest that you write your If statements on 3 lines - this makes it
easier to read and debug your code when you are learning how to use
access.

Another suggestion:
Docmd.Close is better used like this:

DoCmd.Close acForm, Me.Name

Or
DoCmd.Close acForm, "NameOfForm"

If you don't specify what to close, access has to guess.
Your code is easier to read and understand if you are specific about what
is
being closed.

Jeanette Cunningham


Michelle said:
That fixed that error now I get an error that says:
Syntax error (missing operator) in query
expression'[EquipmentID]=12KZ791'
the 12KZ791 is the IDTag for the piece of equipment on the screen at
this
time.
Here is my code:

Private Sub CancelUser_Click()
On Error GoTo Err_CancelUser_Click


If Me.Dirty Then Me.Dirty = False
DoCmd.Close

Exit_CancelUser_Click:
Exit Sub

Err_CancelUser_Click:
MsgBox Err.Description
Resume Exit_CancelUser_Click

End Sub


:

Michelle,
this error: 'Ambigous name detected: Budget_Click', usually means that
you
have 2 different routines both called Budget_Click.
Find the other Budget_Click code and comment it out. Now run the form
and
see if it works.


Jeanette Cunningham


That gives me thie following Error:

The expression On Click you entered as the event property setting
produced
the following error: Ambigous name detected: Budget_Click
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or
macro.
This error occurs when an event has failed to run because Microsoft
Office
Access cannot evaluate the location of the logic for the event. For
example,
if the OnOpen property of a form is set to =[Field], this error
occurs
because Access expects a macro or event name to run when the event
is
fired.


:

Michelle,
in that case, change this line to:

stLinkCriteria = "[EIDTag]=" & Me![IDTag] & ""


Jeanette Cunningham


I am not sure I understand your code or what your trying to have
me
do.
I
would like to know if this will or will not work at all. I have
it
working
in another database the only difference is that in the other
database
the
field is a number not text.

:

Michelle,
use a different approach - the usual way is to set up the main
form
with
one
subform.
Access will automatically create the link Master and Child
fields
for
you,
or you can edit them yourself.
After you have a form and subform setup, you can change the
source
object
that goes inside the subform.
Your command button would change which form shows inside the
subform
control
something like this:

command button to show budgets
Me.SubformControlName.SourceObject = "sfrmBudgeting"

command button to show ip data
Me.SubformControlName.SourceObject = "sfrmIPData"

Note that the subform sits inside the subform control. The
subform
can
have
a different name from the subform control.

Jeanette Cunningham



I have a main from called Equipment it has 2 subforms one for
the
IP
Data
and
one for Budget Data.
When I cleck the command button it opens the sub form however
it
does
not
seem to copy the IDTag to the subfrom IDTag area so that
everything
is
linked
together right.
My Tables are:
tblEquipment
IDTag - Txt & PK
EquipmentType
Location
LocationDesc
Mfg
Model
SerialNum
PONum
Contract
WarType
WarExpDate
Surplus
SurplusDate
InventoryDate
Notes

tblBudgeting
ID - Auto # & PK
IDTag
BdgYear
Expenditure
Purpose

tblIPData
ID -Auto # & PK
EIDTag
MAC
IP
SN
GW
PDNS
SDNS
Wireless

Relationships are:
tblEquipment to tblBudgeting on IDTag = IDTag One-To-Many all
from
tblEquipment and only those from tblBudgeting where fields are
equal.
tblEquipment to tblIPData on IDTag = EIDTag One-To-Many all
from
tblEquipment and only those from tblIPData where fields are
equal.

Here is my code for the command buttons:
IPData
Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmIPData!EIDTag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

Budget
Private Sub Budget_Click()
On Error GoTo Err_Budget_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBudget"

stLinkCriteria = "[IDTag]=" & Me![ID]
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmbudget!IDTag.DefaultValue = Me.ID
DoCmd.MoveSize 3 * 1440, 2 * 1440, 5.4 * 1440, 7 * 1440

Exit_Budget_Click:
Exit Sub

Err_Budget_Click:
MsgBox Err.Description
Resume Exit_Budget_Click


End Sub
 

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