Reference a field on a subform

  • Thread starter gjameson via AccessMonster.com
  • Start date
G

gjameson via AccessMonster.com

I have search through a lot of the old post on referencing things on a
subform but can not get anything to work. What I have is a ticket system and
I want to be able to open tickets from my subform to work them. I am using
the ticket # to link the subform to the frmOpenTicket. I keep getting an
error that it can not find the form. The form is open and I have triple
checked the name for mispellings. Here is the code I am using on the
subTechTicket.

stDocName = "frmOpenTicket"
DoCmd.OpenForm stDocName

Forms!Maint_Log!subTechTicket.Form.Ticket_Number = Me.Ticket_Number

This will open a blank form with the error I mentioned. I have been able to
link other forms from list boxes etc with no problem. This is frustrating.

TIA

Gerald
 
J

John Vinson

I have search through a lot of the old post on referencing things on a
subform but can not get anything to work. What I have is a ticket system and
I want to be able to open tickets from my subform to work them. I am using
the ticket # to link the subform to the frmOpenTicket. I keep getting an
error that it can not find the form. The form is open and I have triple
checked the name for mispellings. Here is the code I am using on the
subTechTicket.

stDocName = "frmOpenTicket"
DoCmd.OpenForm stDocName

Forms!Maint_Log!subTechTicket.Form.Ticket_Number = Me.Ticket_Number

This will open a blank form with the error I mentioned. I have been able to
link other forms from list boxes etc with no problem. This is frustrating.

I don't understand. You're opening a form named frmOpenTicket; your
code is referencing a form named Maint_Log.

What's the relationship between these two forms? Should Maint_Log
already be open by some other action?

John W. Vinson[MVP]
 
G

gjameson via AccessMonster.com

Hi John,
Let me see if I can confuse you more.

MaintLog has a subform called subTechTicket. I have a button on the subform
(Continuous form) that will open frmOpenTicket. No form gets closed during
this action.

Gerald

John said:
I have search through a lot of the old post on referencing things on a
subform but can not get anything to work. What I have is a ticket system and
[quoted text clipped - 11 lines]
This will open a blank form with the error I mentioned. I have been able to
link other forms from list boxes etc with no problem. This is frustrating.

I don't understand. You're opening a form named frmOpenTicket; your
code is referencing a form named Maint_Log.

What's the relationship between these two forms? Should Maint_Log
already be open by some other action?

John W. Vinson[MVP]
 
J

John Vinson

Hi John,
Let me see if I can confuse you more.

MaintLog has a subform called subTechTicket. I have a button on the subform
(Continuous form) that will open frmOpenTicket. No form gets closed during
this action.

Ok, what's the context? Where is this code - in the Click event of a
button on subTechTicket? If so, it's trying to set the value of
Forms!Maint_Log!subTechTicket.Form.Ticket_Number to itself (since Me!
in that context is a shortcut for the name of the form containing the
button) - a do-nothing operation which has nothing whatsoever to do
with frmOpenTicket.

John W. Vinson[MVP]
 
G

gjameson via AccessMonster.com

Thanks John. That is exactly what is happening. Where do I need to move that
statement?

Gerald
 
J

John Vinson

Thanks John. That is exactly what is happening. Where do I need to move that
statement?

Since I have no idea how your tables and forms are structured, nor any
clear idea about what the statement is intended to accomplish, I
really can't say. Could you explain a bit more, bearing in mind that I
cannot see your database?

John W. Vinson[MVP]
 
G

gjameson via AccessMonster.com

Let me see if I can explain. I have a table for customer info and a table for
maint tickets.

Maint Log is a form that has a subform of subTechTicket (info from Maint
tickets table).
The subform displays open tickets for a technician. I want to click one of
the tickets and have another form (frmOpenTicket) open that ticket that was
clicked and edit/close that ticket. I was trying to carry over the Ticket#
field to pull up the right ticket. Do I need to use my primary key for this,
instead of Ticket#? (ID2) I hope this is a little clearer. What would the
best way to do this?
 
G

gjameson via AccessMonster.com

I finally got his to work. After a few more hours of research I came up with
this.
DoCmd.OpenForm stDocName, WhereCondition:="ID2 =" & Me.id2

Thanks for the help.

Gerald
Let me see if I can explain. I have a table for customer info and a table for
maint tickets.

Maint Log is a form that has a subform of subTechTicket (info from Maint
tickets table).
The subform displays open tickets for a technician. I want to click one of
the tickets and have another form (frmOpenTicket) open that ticket that was
clicked and edit/close that ticket. I was trying to carry over the Ticket#
field to pull up the right ticket. Do I need to use my primary key for this,
instead of Ticket#? (ID2) I hope this is a little clearer. What would the
best way to do this?
[quoted text clipped - 5 lines]
John W. Vinson[MVP]
 
Top