What have I done now (1 Viewer)

Gasman

Enthusiastic Amateur
Local time
Today, 22:31
Joined
Sep 21, 2011
Messages
14,265
:banghead:


Went to add a new entry in my DB.
Code for the button is
Code:
Private Sub cmdAddSubmitter_Click()
' Save the record first so the name appears in next form
If Me.Dirty Then
    Me.Dirty = False
End If
DoCmd.OpenForm "frmSubmitter", , , "IntroducerID = " & Me.IntroducerID, , acDialog, Me.IntroducerID
End Sub
Relationship is shown in Intro-Sub pic,
I added the Introducer and then wanted to add the submitter, but when pressing the Add button I get the error in the error pic?


To the best of my memory I have not changed anything in that area since I got it working.?:banghead:


Button is called cmdAddSubmitter and it does not even get into the code?


Tips where to look please.
 

Attachments

  • Intro-Sub.PNG
    Intro-Sub.PNG
    8.9 KB · Views: 178
  • error.png
    error.png
    18 KB · Views: 173

Minty

AWF VIP
Local time
Today, 22:31
Joined
Jul 26, 2013
Messages
10,371
If the form is set to data entry, you can't pass a where clause to it ?
I'm guessing you pass the introducerID in the open args to set that as default on the new record, so not sure why you'd even want a Where clause ?
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:31
Joined
Sep 21, 2011
Messages
14,265
Hi Minty,
At home now, so will check on Monday, but I doubt the form is set to data entry. I have avoided that way of doing things as it has caught me out in the past.?

The WHERE was probably just to show the Submitters for that particular Introducer.

I haven't looked at the target form as I did not even get to the debugging point in that code set at the If Me.Dirty line

In fact I am so sad, I have a copy of the FE at home, and that has Data Entry set to No. I would not have it different in work, but will check.

I *think* I might have made this mistake before, where I mislabled a label with the same name.?

Will need to check on Monday.

Have a good weekend, I am going to try and forget about it until Monday. :D
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:31
Joined
Sep 21, 2011
Messages
14,265
Thank you Paul,

I will investigate that method if I cannot get to the bottom of it any other way.
The form AFAIK has not been touched since first created as I used the same method for other forms.



I had a perfectly good form button that I added a little code to and it suddenly started throwing an error like that. It's a shot in the dark, but this resolved it for me:

http://allenbrowne.com/ser-47.html#SaveAsText
 

jleach

Registered User.
Local time
Today, 17:31
Joined
Jan 4, 2012
Messages
308
Sounds like a bit of corruption to me as well (in which case SaveAsText/LoadFromText should do the trick).

Do you compact/repair often? Regular C/Rs help prevent this (I usually do it every time I take backup of the file, which is just after any significant development is complete... couple times a day at least).

Importing everything into a clean database is another way to help get rid of whatever gunk is causing the issue, as is perhaps running a /decompile on it. In all cases, be sure to grab a backup of the file prior, just in case (they're all invasive operations).

Cheers
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 17:31
Joined
Feb 19, 2002
Messages
43,257
There is nothing obvious in the code. Is there code running in the popup form when it opens?

I did notice a schema problem and if you fix that, the way your form works would change.

The submitter and the introducer are both people and so there is no reason why they can't be in the same table. In fact, is it possible that the same person might be both an introducer and a submitter in a different transaction? If the answer is yes, then all the more reason for using only a single table. That gives you what is called a self-referencing relationship and since it is many-to-many, it would be done in a separate table.

TransactionID
IntroducerID (foreign key to tblPerson)
SubmitterID (foreign key to tblPerson)
other stuff about the transaction....
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:31
Joined
Sep 21, 2011
Messages
14,265
Well it seems a decompile/compile solved the problem.


Will need to remember that as first port of call in the future.:banghead:


Thanks for all the replies.
 

Users who are viewing this thread

Top Bottom