Solved Hello everyone (1 Viewer)

jdcallejas

Registered User.
Local time
Today, 11:53
Joined
Jul 1, 2008
Messages
108
Its been a long time since I have worked on access, I am making a simple invoice database for my own use. Back in the day I remember that there was a code to add new item when selecting from combo box if item didn't exist. I have been looking for this but cant find that code.

So if I have open an invoice and I am on the invoice details and the product does not exists, it use to ask me if I wanted to add this product to the table. It would open the table and added the product.

Can someone help me with that code? Also I want the code to just add the new record without any messages, just simply add the product into the product table.

To make things easy I will be using a barcode reader so this way it faster.

My products don't have prices or quantity its just the code.

thank you
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:53
Joined
Oct 29, 2018
Messages
21,360
Hi. Welcome to AWF! Have you tried using the List Items Edit Form property? Or, if you don't want any messages, maybe just set the Limit To List property to No.
 

bastanu

AWF VIP
Local time
Today, 08:53
Joined
Apr 13, 2010
Messages
1,401
Hi there,
I think you want to use the NotInList event to add a new product to your table. Here is a link to do that:
Cheers,
Vlad
 

jdcallejas

Registered User.
Local time
Today, 11:53
Joined
Jul 1, 2008
Messages
108
Thank you!!!! Thats what I didnt remember...
Hi there,
I think you want to use the NotInList event to add a new product to your table. Here is a link to do that:
Cheers,
Vlad

Hello again,
Can you help me with the code. I want to use the not in list event but I just want it to add new item without any questions.

Let me explain,
The company company serves breakfast, lunch and dinner to about 800 employees. They come through the buffet line just like we did back in highschool.
The way it's being done right now is that each one has a ticket.
All employees have an ID card with a barcode, so my idea is that can use a barcode reader to scan the barcode.
The thing is that the company hires people every week, this is a shrimp processing plant. So every week we have new personnel.
This is why I want to be able to automatically add the new employee without any questions on the not in list event

Thank you
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:53
Joined
Oct 29, 2018
Messages
21,360
Thank you!!!! Thats what I didnt remember...


Hello again,
Can you help me with the code. I want to use the not in list event but I just want it to add new item without any questions.

Let me explain,
The company company serves breakfast, lunch and dinner to about 800 employees. They come through the buffet line just like we did back in highschool.
The way it's being done right now is that each one has a ticket.
All employees have an ID card with a barcode, so my idea is that can use a barcode reader to scan the barcode.
The thing is that the company hires people every week, this is a shrimp processing plant. So every week we have new personnel.
This is why I want to be able to automatically add the new employee without any questions on the not in list event

Thank you
Hi. If you use the NotInList event, the question doesn't come up if you use the Response argument.
 

zeroaccess

Active member
Local time
Today, 10:53
Joined
Jan 30, 2020
Messages
671
Am I the only one who read "Hello everyone" in Steve Bishop's voice?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:53
Joined
May 7, 2009
Messages
19,175
Code:
Private Sub cboProduct_NotInList(NewData As String, Response As Integer)
    CurrentDb.Execute "insert into yourTable (ProductCodeFieldName) select '" & NewData & "'"
    Response = acDataErrAdded
End Sub
 

jdcallejas

Registered User.
Local time
Today, 11:53
Joined
Jul 1, 2008
Messages
108
Code:
Private Sub cboProduct_NotInList(NewData As String, Response As Integer)
    CurrentDb.Execute "insert into yourTable (ProductCodeFieldName) select '" & NewData & "'"
    Response = acDataErrAdded
End Sub
This is exactly what I needed!!!! Thank you!!!
 

jdcallejas

Registered User.
Local time
Today, 11:53
Joined
Jul 1, 2008
Messages
108
Code:
Private Sub cboProduct_NotInList(NewData As String, Response As Integer)
    CurrentDb.Execute "insert into yourTable (ProductCodeFieldName) select '" & NewData & "'"
    Response = acDataErrAdded
End Sub

Hello Arnelgp,

I have a question, I have the subinvoice table working great, the new records are being added automatically into the employee table. Now i have another task. I have made the empID on the subform No Duplicates, So now when I try to input the same employee I get the error msg.. This is great, I dont want duplicates, but how do I make it so the msg says "The employee has allready checked in" vbOK type of msg.. What code is it and where would I input this code?
 

jdcallejas

Registered User.
Local time
Today, 11:53
Joined
Jul 1, 2008
Messages
108
1587251738704.png



How can I change that msg to a custom msg and after clicking ok on the msgbox field goes blank...
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:53
Joined
May 7, 2009
Messages
19,175
add code to the Subform's BeforeUpdate Event or on the Textbox BeforeUpdate event.
this is an example on the textbox event (the one being covered by the message box on your post #11):
Code:
' replace "the_codigo_textboxName" with the correct textbox name
Private Sub the_codigo_textboxName_BeforeUpdate(Cancel As Integer)
With Me.RecordsetClone
    .FindFirst the_codigo_textboxName.ControlSource & "=" & Chr(34) & Me.the_codigo_textboxName & Chr(34)
    If Not .NoMatch Then
        Msgbox The employee has already checked in", vbInformation + vbOkOnly, "Message"
        Cancel = True
    End If
End With
End Sub
 

Users who are viewing this thread

Top Bottom