Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form name issue

Status
Not open for further replies.

newbieone

Technical User
Jan 3, 2006
50
US
I had a working database that would check to see if the person was trained in an area and also any available personal information stored. Now I want to change some code but for some reason VB/Microsoft can't find one of the forms. It's there I can see it but the form name has changed. anyone know how to verify the name of a form?
 
not sure if i'm getting you right, but it seems what you think the form name is is actually the caption asssigned to the form (the name in the top bar)

can you not simply go into the database with a shift, navigate to the form then design and your actual form name should be in the top corner, that is if its in access!!!

again, sorry if i'm not getting what you mean!!

cheers

daveJam

*two wrongs don't make a right..... but three lefts do!!!!*
 
Sorry yes I am using Access 2003. I thought if clicked on the form properties it would show you the form name above the actual control source. however, my database doesn't do this. so I am trying to figure out where to go to find the actual form name.
 
If you are looking at your form in Design View, then the form name should be in the title bar.

I.E. "frmMyForm: Form
 
It is, which does not explain why the code is blind to this form. this is the error I am getting. I have the DAO 3.6 library. "Run-time error '2450'. Microsoft Access can't find the form 'Trainingfrm' referred to in a macro expression or Visual Basic code.
 
Private Sub cmdCloseApp_Click()
On Error GoTo Err_cmdCloseApp_Click

Dim strContactID As String
Dim strContactqryID As String
Dim strTrainingqryID As String
Dim strAccreditqryID As String
Dim strTrainingID As String
Dim strAccreditID As String
Dim StrFName As String
Dim strLName As String


strContactqryID = "ContactsCountqry"
strTrainingqryID = "TrainingCountqry"
strAccreditqryID = "AccCountqry"
strContactID = Forms!Contactsfrm!ContactID
StrFName = Forms!Contactsfrm!FirstName
strLName = Forms!Contactsfrm!LastName


If strContactqryID <> strTrainingqryID Then

Do
DoCmd.GoToRecord , , acNewRec
Forms!Trainingfrm!TrainingID = strContactID ' this is the code that is blowing up and giving me the error
Forms!Trainingfrm!FirstName = StrFName
Forms!Trainingfrm!LastName = strLName
Loop Until strTrainingID = strContactID


' If strContactID <> strAccreditID Then
' MsgBox "both are not equal"
MsgBox "not equal"
End If
' End If
 
First step:Double check the spelling. make sure nothing as simple as

TrainingForm
TrianingFrm
etc.

Is this form open when the code is running?
 
When this code is running, is the Trainingfrm open? I just ran a test and got the same error, but it was because the form I was referencing was not open.
 
no the form was not open when I got the error. is it possible that the default file format for the database is causing the issue? Mine says it's set to Access 2000 even though I am working in 2003.
 
No, it's because your code is attempting to assing the value of a text box control on a form that isn't even open.
 
Like rjoubert said you can not reference a form using the forms collection if it is not open
Use the Forms collection in Visual Basic or in an expression to refer to forms that are currently open.
[/qote]

If you need to reference a closed form use the forms class

form_Trainingfrm
 
please explain "forms Class" this is a new term for me.
 
Interesting, however, this link states that it's only for open forms. how do I reference a closed form? or do all forms have to be open in order for code to run correctly?
 
It would be easy if you just run an insert query. Not to worry if the form is open or not.

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
If you're trying to set the value of a textbox on another form, the form would have to be open. I believe MajP answered your "reference a closed form" question in his last post.
 
why don't you try it, but open the form before the code,
Code:
docmd.openform "trainingFrm"

you can even open it as hidden!!

then you can always close the form after the process has run!!

daveJam

*two wrongs don't make a right..... but three lefts do!!!!*
 
i do agree with ZmrAbdulla, if you are doing it in code you may aswell create it as an insert. depends on your circumstances.

daveJam

*two wrongs don't make a right..... but three lefts do!!!!*
 
No reason why I couldn't do the insert instead. Just thought the database would be less chunky without all the queries. But,I am open to new things, so let me give this a try and see how it works. Thanks for all your help everyone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top