help needed, brain gone! (1 Viewer)

mike60smart

Registered User.
Local time
Today, 21:17
Joined
Aug 6, 2017
Messages
1,909
im not sure i can do that as this db uses 3 data links 1 to a local sql server and the other 2 link to 2 web based databases setup in phpmyadmin so without the data the forms dont really work and you wouldnt be able to test it very well. this single form is the main form order form in a massive database that does all sorts which I visit 3 times a week, and this issue is just bugging me that it cant get it working.
It must be a linking problem.

If you have a subform with Multiple records then the linking PK/FK autopopulate as in the following example:-
If you then delete a record then the PK will autopopulate with (New) and the FK will populate when you enter the first Data in a Control.
 

Attachments

  • Multi.jpg
    Multi.jpg
    37.4 KB · Views: 49
  • Deleted.jpg
    Deleted.jpg
    26.8 KB · Views: 52

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:17
Joined
Feb 19, 2002
Messages
43,280
but thats becuase the correct code simply didt work,
Then it wasn't actually correct;) Or, perhaps it was "correct" code but in the wrong event so it wasn't being executed when you thought it would/should be.
i cant use the delete command he sugests either becasue it remove it from view but the record reappears when you reopen the form
That means the record isn't actually being deleted. Why? Is the form bound to a query that includes a join to a second table? If so, the delete action works against the child table, not the parent table. You need to split into a form/subform.

The 3101 error can be caused in two situations that I am aware of.
1. The master/child links are not correctly set so Access isn't populating the FK for you.
2. Your subform is joined to the main form record (it shouldn't be) and instead of selecting the FK field from the child record, you selected the PK field from the parent record.

If you can isolate the forms and tables related to this issue in a separate database, we have a better shot at figuring out the problem.
 

dtdukes86

Member
Local time
Today, 21:17
Joined
Aug 14, 2021
Messages
83
It must be a linking problem.

If you have a subform with Multiple records then the linking PK/FK autopopulate as in the following example:-
If you then delete a record then the PK will autopopulate with (New) and the FK will populate when you enter the first Data in a Control.
i completly agree mike the word new should be in the new record but using sql the word new dosnt show up what i usually see on other forms is the id field staying empty untill the record is saved, and this form does do that perfectly untill you try adding a record after the delete, im going to have another little play with it today so fingers crossed
 

dtdukes86

Member
Local time
Today, 21:17
Joined
Aug 14, 2021
Messages
83
Then it wasn't actually correct;) Or, perhaps it was "correct" code but in the wrong event so it wasn't being executed when you thought it would/should be.

That means the record isn't actually being deleted. Why? Is the form bound to a query that includes a join to a second table? If so, the delete action works against the child table, not the parent table. You need to split into a form/subform.

The 3101 error can be caused in two situations that I am aware of.
1. The master/child links are not correctly set so Access isn't populating the FK for you.
2. Your subform is joined to the main form record (it shouldn't be) and instead of selecting the FK field from the child record, you selected the PK field from the parent record.

If you can isolate the forms and tables related to this issue in a separate database, we have a better shot at figuring out the problem.
thank you for this pat i will look into this now and see if i cant simplfy thing a little.
 

dtdukes86

Member
Local time
Today, 21:17
Joined
Aug 14, 2021
Messages
83
@Pat Hartman took on board what you said and rechecked the record set for the sub qry, made a slight change and removed one of the tables that wasnt critical and it works perfecly , very strange,. but done thank you .
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:17
Joined
Feb 19, 2002
Messages
43,280
Not strange at all once you understand how delete actions work. Glad you worked it out.
 

Users who are viewing this thread

Top Bottom