Solved What is locking my form?

thank you very much. Ahaa ok I see I have to use On Current.
I have the code on load event so I will change all that and I will observe if I will notice again strange lockings on the forms.
 
Hello I am back

for some reason I can not find what locks my form for entering data.
Someties all the fields are grayed and sometimes data entry is set No. All that happens automatilcly...hmmm 🤔
Like I say before I am using some code in my On current event for some protecion from the user from changing data in specific fields. I am sure that this is not causing my problem. :cautious:

In my forms I use Data entry = yes. I need that becouse I need that user always start entering data in new record.
Becouse sometimes my form is locked I mean data entry is set to No I just start using
I thougt that was my solution I was happy and now I am just worried again :oops:


Private Sub Form_Load()
DoCmd.RunCommand acCmdRecordsGoToNew
End Sub

And that works 95% in all the forms..
only One form is now causing me the problem with the ms access error 2046 that says me: can not go to add new record !! i receive the error and then forms opens for adding new record...well I dont like that error now....

and access debug me in yellow my code from the Load event

hmmmm

what I am doing wrong? what could be the problem?

Private Sub Form_Load()
DoCmd.RunCommand acCmdRecordsGoToNew
End Sub
thanks
 
for some reason I can not find what locks my form for entering data.
It's your own code. If you want us to figure it out, you will need to post the database.
 
Hi Pat
Yes I am sure that must be some my mistake.

Well now I put in the form properties the form in dialog yes
and now on load event is no errror?? hmmm very strange
I will continue testing to see if the error will apperar again ohhhhh :cautious:

Before I have in this way: now I just delete the acDialog
hmmmmmmm
Private Sub btnUporabiOdrezZaAnalizo_Click()
DoCmd.OpenForm "frmUporabaOdrKapSUB", , , "OdrezID = " & Me!OdrezID, acFormEdit, acDialog
End Sub
 
It is always best to open popup forms as dialog. That way they retain the focus until they close plus the code stops running in the calling form so it picks right up when the popup for closes.
 
Not sure if it has been mentioned already, but DataEntry should be No (False)

If Data Entry is True, you can't see existing records with the form, and it can only be used to enter new records. Hence Data Entry. If Data Entry is false. then you can still enter new records, but you can also see all existing records, which is a more general approach.

if you can't enter new records, most likely your form query is not updateable, but this would most likely be a permanent problem. It shouldn't let you enter records sometimes and not enter them at other times.
 
OK I will think what to do i will do a lot of testing
I am entering into new entry from some another form. They are connected.
Becouse of that I set Data entry to Yes...but now i am thinking to make some button so the user will click that button to enter new data.
ohhh i just wanted to be more easier for the user and it seem that then is more complicated for me.
thank you
 
I'm sure there are reasons for using data entry property = yes as the default but I would never do that. With the OpenForm method, you have the option of opening a form in various modes, one of which is data entry so I just leave the dataentry property = no on the form.

docmd.OpenForm "",acNormal,,,acFormAdd,acDialog,Me.SomeID

Using "acFormA" opens the form for data entry
Passing in the ID of the parent record as the OpenArgs value gives you an easy way to set the FK. That way, in the form's BeforeInsert event, you can populate the FK

Me.SomeFK = Me.OpenArgs

This gives you the ability to have TWO buttons if that is what you really want (again, I would never do this). The other button can open the form for edit which ALSO allows the form to add new records.

docmd.OpenForm "",acNormal,,"SomeID = " & Me.SomeID,acFormEdit,acDialog,Me.SomeID

In this case, you change to using acFormEdit AND you have to use a where clause so that the popup opens to show existing data.

You need to ask the user if it is more likely that he will be opening the form to add new records than to look at existing records and possibly add a new one. Opening the form using acFormAdd PREVENTS the user from seeing existing data. I'm not sure that mode is as useful as you think. Since this isn't actually a subform, you still have to populate the FK in the BeforeInsert event regardless of how you open the form.
 
Well I think that my situation is very complicated. But I will try what you all suggest me today. To set Data entry to No.

I need that users always when choosing records from form A and when going to the form B to enter data like new record. User just need to enter data.

If he want to see previus specific ID record he choose the specific ID record and opened in. If the record is approved then all the fields form that specific ID are locked, so in that specific ID record he can not change data anymore.

1. User enter new data in form A
2. In form A is some buttonA who say Use that item A for something ( usage of some item)
3. User click the buttonA and open form B ( here the form must be empty, he must enter new record) with some another buttons, one imortant is button sign record let say button C
4. User enters all the data in the form B and then he click the button C and first sign the record
5. then came approver he open specific record that mean form B and he also click the button C to sign the record- he approved the record
6. if user want to check if all is signed and locked- he click again the form B he choose the specific ID record and check the data

what is best correct approach to make that? I will try like you suggest me, I am just wondering if you experts would like do that in another way.

Now I have in the same way like I described, but becouse sometimes the forms go locked ( I have to find what is the problem) I just start to use on Load event code to go automaticly to add new data, then with a lot of testing realise that the problem is now in the load event
So i delete load event and now again the form is working but sometimes is locked and sometimes no..hmmmmm

ohhhh 🤔
 
Well I think that my situation is very complicated
I'm pretty sure you are over thinking this. If a record is always locked or unlocked, then handling that is very simple and you do it in the form's on Dirty event. If the form is locked, you undo the typing and tell the user he can't change the record.

Code:
If Whatever = locked Then
    Msgbox "You may not update this record.",vbOKOnly
    Me.Undo
    Exit Sub
End If

It is only when the locking varies by field that you have to lock fields ahead of time in the form's Current event.

It is difficult and annoying to the user to try to totally control the order of things, especially when separate users are involved. Generally, the table bound to the main record would have an approved flag (violates normal forms but makes the rest of the process easier.). NO process can use the main record or its children unless the record is approved so Only the edit forms work with these records. If each record needs to be verified by itself, then in the AfterUpdate event of the child table, you Count the verified and unverified records if verified is >= 1 and Unverified = 0, then you update the main record to set the approved flag.

If you want to decide whether to open the popup as add or edit, you can count the number of child records. If it is > 0, then open the popup in edit mode otherwise open it in add mode.
 
The point was that setting DataEntry = NO (the default) is not normally an error and does NOT mean that you cannot add any new records.

Data Entry = YES, is for a special type of Data input form, where you might have clerks who need to enter new records, but never need to examine old records as part of that process. Hence, just a form for (new) Data Entry. Each time you open the form the record count for the current session starts again at Zero.
 
I have to say that I am very stupid. :cautious:
I make a mistake and becouse of me the form was all the time locked.
When I have a record ID signed ( here all the field are disabled, greyed) then from that record I make another entry...and becouse I use AcFormEdit the fields were all disabled, only when I make the first record the field were empty and then all the time disabled. Becouse of that i was saying that sometimes is locked sometimes no.
I thought if I use DataEntry Yes the form will always open new entry. That was true but then with AcFormEdit i make the another mistake.
Now i change to AcFormAdd and I think I finally managed to work. I will make a lot of testing to confirm my conclusion. ohhhh
I am so sorry experts it was my fault.
Thank you to all for your suggestion.
I use Pat solution to use AcFormAdd and now seems ok and I also change DataEnty to No.
 

Users who are viewing this thread

Back
Top Bottom