Kamis, 21 Mei 2020

Re: [MSAccessProfessionals] Form not working as expected

You should not have to save the record and you should move away from using DoCMd.DoMenuItem. There are better alternatives.
I would also not be satisfied with a combo box named "Combo5". Kick your development up a notch and provide appropriate names to objects that matter ðŸ˜‰

As I stated earlier, I would add this functionality to a separate button or double-click event.


Private Sub Combo5_NotInList(NewData As String, Response As Integer)

Dim sMsg As String

sMsg = MsgBox("Name not found.  Do you wish to add this new record?", vbYesNo)
If sMsg = vbYes Then
    DoCmd.OpenForm "frmfoodcust", , , , acAdd, acDialog
    Me.Combo5.Requery
End If


Duane


From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> on behalf of M Garcia via groups.io <toukey1=yahoo.com@groups.io>
Sent: Thursday, May 21, 2020 6:23 PM
To: msaccessprofessionals@groups.io <msaccessprofessionals@groups.io>
Subject: Re: [MSAccessProfessionals] Form not working as expected
 
Ok so I'm back with this same combo box.

I took the recommendation of having a separate form to enter the customer information if the customer name is not in the combo box to be selected and there would have to be a requery of the list in the combo box.  Where would this requery go? On the combo box or the form?

I tried the following on the combo box:

Private Sub Combo5_NotInList(NewData As String, Response As Integer)

Dim sMsg As String

sMsg = MsgBox("Name not found.  Do you wish to add this new record?", vbYesNo)
If sMsg = vbYes Then
    DoCmd.OpenForm "frmfoodcust", , , , acAdd, acDialog
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70  ------ is this needed?
End If

When the frmcust form opens, I enter the customer name etc and exit the form which brings me back to first form but with the message "Name not found.  Do you wish to add this new record?", vbYesNo and it loops.

Is it that I have to clear the contents of the combo box and if yes, where do I put that code?  Is it combo5 = "" ?

I'm threading on new ground here.  Forgive me!

Regards
Mercy






On Tuesday, May 19, 2020, 05:59:04 AM AST, Graham Mandeno via groups.io <graham=mandeno.com@groups.io> wrote:


Hi Mercy

I totally agree with Duane here.  How much information do you want to store about a customer?  Just a name and whatever other identifying information appears in the combo box?  I don't think so!  You will maybe want to store postal and delivery addresses, email address, phone numbers, contact names, payment details, and all kinds of other stuff.

It is really easy to add a new record from a NotInList event procedure, but obviously the only data that can be in that record is what the user typed into the combo box, that wasn't in the list.  How is the user going to record all that other data if you don't open a separate form?

Best wishes,
Graham Mandeno [Access MVP 1996-2017]

From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> On Behalf Of M Garcia via groups.io
Sent: Tuesday, 19 May 2020 07:53
To: MSAccessProfessionals@groups.io
Subject: Re: [MSAccessProfessionals] Form not working as expected

 

Sure!  Thanks for all your assistance.

 

Regards

 

 

 

On Monday, May 18, 2020, 03:03:28 PM AST, Duane Hookom <duanehookom@hotmail.com> wrote:

 

 

IMO, if your user needs to create a new customer then give them a form to do it properly. This isn't a big deal.

 

Duane

 


From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> on behalf of M Garcia via groups.io <toukey1=yahoo.com@groups.io>
Sent: Monday, May 18, 2020 1:59 PM
To: msaccessprofessionals@groups.io <msaccessprofessionals@groups.io>
Subject: Re: [MSAccessProfessionals] Form not working as expected

 

Understood but trying to avoid the creation/opening of another form to add the customer.

 

I think the LimitToList would work if the combo box was on the custname and not customerid which was suggested in one of your earlier emails. Refer to below for ease of reference.

 

Note I am able to select the customer name fine with the combo box on customerid

 

    

    On Friday, May 8, 2020, 06:39:18 PM GMT-4, Duane Hookom <duanehookom@hotmail.com> wrote:

 

 

    If you are tracking customer visits, then you need a table with at least these fields:

 

    CustomerID

    VisitDate

 

    You would typically add data to this table using a subform on a Customer main form. You could also simply     create a form based on this table with the CustomerID bound to a combo box to select the appropriate     customer.

 

 

Regards

Mercy

 

 

 

My typical strategy is to allow the user to search for the customer in the drop down. If they don't find a record, ask them to click a button to add a new customer. This button would open a customer form in dialog mode for them to create a new customer record. The code following the dialog form opening would requery the combo box and perhaps position the combo box to the most recently added customer.

 

Duane

 

 


From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> on behalf of M Garcia via groups.io <toukey1=yahoo.com@groups.io>
Sent: Monday, May 18, 2020 1:01 PM
To: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io>
Subject: Re: [MSAccessProfessionals] Form not working as expected

 

Yes - the first column which is the CustID field was 0" so I changed it to 1".  After that change and I entered a name in the combo box I got the error "The value you entered isn't valid for this field."

 

 

 

On Monday, May 18, 2020, 01:11:04 PM AST, Paul Baldy <pbaldy@gmail.com> wrote:

 

 

The obvious first question is did you address the issue noted in the error message?  Presuming the bound column is 1, the first column width can't be 0.

Paul

Tidak ada komentar:

Posting Komentar