UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Combobox Isnt Recording Data Onto Table, Access 2013    
 
   
MrWrap2
post Dec 4 2019, 02:14 PM
Post#1



Posts: 121
Joined: 10-January 17



Good afternoon,

In an attempt to break down some of the larger issue into more digestible problem sets from my earlier post (Personnel In/Out with the ability to In/Out Equipment) I'm quickly running into coachable moments.

In this post, I'd like to achieve a combobox on a form that will populate data to a table (this seems super basic, but I am obviously missing something).

In preparation I created: tblKeyAuthorizationLevel and qryKeyAuthorizationLevel

I modified frmAddEmployee and inserted a new unbound combobox [cboKeyAuthorization] (between cboAccessLevel and txtCACBack) and applied the below as the row source for cboKeyAuthorization:

SELECT [qryKeyAuthorizationLevel].[Key_Authorization], [qryKeyAuthorizationLevel].[Key_Auth_Instructions_abr], [qryKeyAuthorizationLevel].[Sort_Order] FROM qryKeyAuthorizationLevel ORDER BY [Sort_Order];

I then modified the After Update event for new cboAccessLevel as follows:

CODE
Private Sub cboAccessLevel_AfterUpdate()
Me.cboKeyAuthorization.SetFocus
End Sub


and cboKeyAuthorization to:

CODE
Private Sub cboKeyAuthorization_AfterUpdate()
Me.txtCACBack.SetFocus
End Sub


the last field in the form is txtCACBack which has the following for Event After Update:

CODE
Private Sub txtCACBack_AfterUpdate()

On Error GoTo Error_Handler

If Len(Me.txtCACBack) <> 18 Then
  MsgBox "Invalid Barcode Scanned."
   Me.txtCACBack.Value = ""
   GoTo CleanUpAndExit
      Else
  
   End If

'Check if Member exist

Dim rst As DAO.Recordset
Dim db As Database
Dim strSQL As String
strSQL = "SELECT tblEmployees.EmployeeID FROM tblEmployees WHERE (((tblEmployees.EmployeeID)='" & [Forms]![frmAddEmployee]![txtCACBack] & "'))"

Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)
'rst.MoveLast
If Not (rst.EOF And rst.BOF) Then
MsgBox "Member not added. An account for this member already exists.", vbExclamation
GoTo CleanUpAndExit
Else
End If

DoCmd.SetWarnings False
DoCmd.OpenQuery "qryAddEmployeeAppend"

Me.txtCACBack.Value = ""
Me.txtCACFront.Value = ""
Me.txtFirst.Value = ""
Me.txtLast.Value = ""
Me.txtGrade.Value = ""
Me.txtServiceandGradeIndicator.Value = ""
Me.cboUIC.Value = ""
Me.cboSection.Value = ""
Me.cboAccessLevel.Value = ""
MsgBox "Employee Added"
Me.txtCACFront.SetFocus

GoTo CleanUpAndExit:

Error_Handler:
MsgBox "An error occured.  Report error 101 to your system manager."

CleanUpAndExit:
DoCmd.SetWarnings True

If Me.txtAutoClose.Value = -1 Then
Else
DoCmd.Close acForm, "frmAddEmployee", acSaveYes
Forms![Check In/Check Out].SetFocus
Forms![Check In/Check Out].txtCACBack.SetFocus

End If

End Sub


After txtCACBack updates, all the information is populated to the tblEmployees, likely by way of a qry (or at least so I assume EXCEPT for the cboKeyAuthorization data.

How do I achieve this? I'm guessing I need to add to the qryAddEmployeeAppend along the lines of:

Field: KeyAuthorizationLevel: CStr([Forms]![frmAddEmployee]![cboKeyAuthorization])
AppendTo: Key_Authorization_Level

thoughts?

Thanks in advance,
-Mike



Attached File(s)
Attached File  tbls___qry.JPG ( 169.92K )Number of downloads: 0
Attached File  frmAddEmployee.JPG ( 47.36K )Number of downloads: 0
 
Go to the top of the page
 
theDBguy
post Dec 4 2019, 02:15 PM
Post#2


UA Moderator
Posts: 76,866
Joined: 19-June 07
From: SunnySandyEggo


Hi Mike. What did you put in the Control Source property of the Combobox?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
MrWrap2
post Dec 4 2019, 02:36 PM
Post#3



Posts: 121
Joined: 10-January 17



theDBguy,

the control source for cboKeyAuthorization is empty.... however,

After reviewing the After Update for txtCACBack, I was able to determine that qryAddEmployeeAppend needed to have the Key Authorization information collected, so I added a field to the qry, then modified the VBA to include

CODE
Me.txtCACBack.Value = ""
Me.txtCACFront.Value = ""
Me.txtFirst.Value = ""
Me.txtLast.Value = ""
Me.txtGrade.Value = ""
Me.txtServiceandGradeIndicator.Value = ""
Me.cboUIC.Value = ""
Me.cboSection.Value = ""
Me.cboAccessLevel.Value = ""
[b]Me.cboKeyAuthorization.Value = ""[/b]
MsgBox "Employee Added"
Me.txtCACFront.SetFocus


this appears to have resolved the issue! #ImLearning!!
Go to the top of the page
 
theDBguy
post Dec 4 2019, 03:20 PM
Post#4


UA Moderator
Posts: 76,866
Joined: 19-June 07
From: SunnySandyEggo


Hi. Glad to hear you got that part sorted out. Cheers!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    11th December 2019 - 08:27 AM