Command Button help please

eric1066

Registered User.
Local time
Today, 07:46
Joined
Nov 13, 2009
Messages
11
Hi,

I have created 2 forms for 1 table as I have too many fields. I created a command button button in the 1st form to open the 2nd form to continue adding data, but the second form is not opening to the right record.

I chose the option to open to specific record and used the ID field which is the only field the two forms share as the means of searching, yet it doesnt work the 2nd form keeps opening to the 1st record.

The macro argument to the 'OpenForm' action:
DIP Details Form, Form, , "[PDID]=" & "'" & [PDID] & "'", , Normal

Any help is greatly appreciated!!

Thanks,
Eric
 
Rather than two forms, have you considered using a tab control to organize the fields on one form?
 
Oooh great Idea!

One problem though, I have a code behind the form which worked fine before but is giving me an error now.

Error message:
Compile Error
Method or data member not found

Its highlighting this:
Private Sub Form_Current()
 
I've never seen it error there. What's the full code for the current event?
 
ok, i figured it out. The code was refering to some textboxes, which for some reason their 'name' changed from the name to 'textnnn' in this case text183, I changed it back and it works now!

Thanks anyways!
 
Since you brought it up, you really, really, really need to not accept the names Access assigns controls, like textboxes, when they are created, but rather give them names that are descriptive and will mean something to you, down the road, or to anyone else who follows you in working with this app.
 
Thanks for the response missinglinq, if you read my post I do state that the original names, (which I gave) were changed upon switching to tabbed pages to 'textnnn' such as text183. so I had to go and change these back. I understand your point though.

Anyways, the code is working again sort of... the afterupdate isn't working anymore, here is the code:

Private Sub Form_Current()
If Me.JointApp = True Then
Me.FirstName.Enabled = True
Else
Me.FirstName.Enabled = False
End If
End Sub

Private Sub JointApp_AfterUpdate()
If Me.JointApp = True Then
Me.FirstName.Enabled = True
Else
Me.FirstName.Enabled = False
End If
End Sub

Basically, I have a checkbox called JointApp and when ticked the relevant textbox is enabled. This still happens but only if you change record and go back to the record, before this would happen automatically and instantly.

also, it would be nice if I could refer to that same checkbox from the next tab page but i'm not sure if there should be a reference to the tabs in the code or whether it is all one form.

Any help appreciated,
Eric
 
Last edited:
Tab controls are not considered when referring to controls. Controls on any tab are just on the form.

Are you sure the code in the after update event is running? Make sure the code is still associated with the control in the control's property window. You could throw a message box in there to test.
 
Sorry, I missed the part about the textbox names "changing!" Although, I have to say, I've never heard of this happening, and have to wonder about possible corruption.

As to the AfterUpdate event working, I suspect Paul is right on the money, assuming that JointApp was originally on the form and has now been moved onto one of the tabbed pages. When you do this, you have to "re-connect" the control to it events.

Select the control, then go to Properties - AfterUpdate and click to the right of the box that says [Event Proceedure]. This will take you to the code module and the control and its event will be "re-connected" and work as before.
 
thats exactly what it was, solved now.

Thanks EVERYONE!!! Really appreicate the help!

Eric
 
No problemo, glad we got it sorted out.
 

Users who are viewing this thread

Back
Top Bottom