I tried setting that to >1 and still wont edit?
I tried setting that to >1 and still wont edit?
Test Buttons-davegri-V01.zip
This should be a lot closer to what you want.
Hi davegri,
That works so nicely, cant thank you enough. If I can get my edit figured out I am all set. Thank you so much! Perfect!
Dave
Hi davegri,
I waslooking over and I see a Private Sub GetRecordToEdit(KeyArg As Long), do I need to call this on my edit button or save button also? I hit edit button, edit record, and save, then it fires the code before update and doesn't save the record?
Thanks
Test Buttons-davegri-V02.zip
Didn't test that, not realizing you might just edit the displayed stored rec.
Added public boolean variable eMode.
Last edited by davegri; 12-03-2018 at 12:24 PM. Reason: clarif
Thank you,
That works like a charm. You are a genius!
I really appreciate this.
Dave
Hi davegri
I really hate to ask but could i get a look at the CboStateID_NotOnList as i have been working on it all day and cannot get it past errors. I use to be able to do that but has been so long i just cant figure out what i am doing wrong with trying to get a not on list event on the cboStateID field. the code below is what I was working with and will open form, but I cant get it to save it so I can put it in my Frm_City without closing it. I have placed requery at various point with no success, they have been removed. I also attached the db.zip. I really hate to ask for help on this one but I just cant get it past error.
Thanks
dave
Code:Private Sub cboStateID_NotInList(NewData As String,Response As Integer) Dim ctrl AsControl Dim strMessageAs String Set ctrl =Me.ActiveControl strMessage ="Add " & NewData & " “ IfMsgBox(strMessage, vbYesNo + vbQuestion) = vbYes Then DoCmd.OpenForm "frm_State", _ DataMode:=acFormAdd, _ Windowmode:=acDialog, _ OpenArgs:=NewData ' ensurefrm_State closed DoCmd.CloseacForm, "frm_State" ' ensurecontact has been added If NotIsNull(DLookup("StateID", "Tbl_State", “TxtState = ” & _ NewData& """")) Then Response =acDataErrAdded Else strMessage= NewData & " was not added to State table." MsgBoxstrMessage, vbInformation, "Warning" Response = acDataErrContinue ctrl.Undo End If Else Response =acDataErrContinue ctrl.Undo End If End Sub
Maybe you attached the wrong DB. There is no VBA in the attached DB.
I also can't tell from your description what form is the problem.
Test Buttons-davegri-V02.zip
Hi davegri,
I dont know what happened on the upload. I have attached a new copy of it. I was trying to use the code above for a NotOnList event in my frm_Cities. It would open the form, let me add a record, save and close, but wouldn't update the cbo_StateID and came up with "Restriction" error when I fired the not on list event. Ideally, I wanted to use a not on list on the cboStateID, Open frm_State, have the Txt entered into the filed State that I was trying to add, Set focus on the StateName, Enter State Name, Save, Close form, and have that entered into my open frm_Cities! That would be the ideal case. Something about the not in list is not working with my current code in the before update event in Frm_Cities
Thanks Again
Dave
HI davegri,
I have been working on this and have almost got it working correctly. I have attached the newest work here. Now, if I click add in frm_City, type in new city, tab to state, enter a new state (Like CC) or something else that is not in list, then msgbox do you want to add, yes, and then the restriction comes up from before update event, then it opens up Frm_State, lets me enter info (however, the Txt I entered doesn't transfer to State) but then I enter the info and hit save, hit close, then msgbox "Text you entered not in the list" Please select.....OK, Then if you go back to list, its in the list.
I beleive this will work, just need to figure out the errors.
\
Thanks
Dave
Test Button NOL.zip
Test Buttons-NOL-V01.zip
This should not be so complicated. I've simplified the method of Not in list to automatically open the state form via the state combobox property in the city form. The not-in-list code is commented out.
You should really look at other ways to eliminate the confusing jumble of code.
Thanks davegri,
That works good. I am learning slowly and have enrolled in a coarse that starts in Jan for Access and VBA so that should help.
Have a great day and thanks again.
Dave