Not in list combo questions



I am a newbe at VB and have a couple of questions I hope someone can answer.

I have a combo box that will prompt to open a form to add a new record for
an item not in the list and it seems to work fine.

Question 1. Is there a way to populate the field in the new record form with
the data previously entered in combo box? The new record form opens in
dialog which stops the code from running. It will work if I open the form in
normal mode but error msgs are created because the new data hasn't been
entered yet.

Question 2. After entering the new data and closing the add record form, I
can select the new record if I scroll to the bottom of the list. Is there
any way to have that record already selected when I return to this form from
the add new record form?

Here is the code I am using so far:


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

On Error GoTo ErrHandler

MsgBox "Please double-click this field" & vbCrLf & _
"to add a new VIN to the list.", _
vbInformation + vbOKOnly, "No Matching Record"
Response = acDataErrContinue

Exit Sub

ErrHandler:

MsgBox "Error in cbotblvinID_NotInList( ) in " & Me.Name & " form." & _
vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.description
Err.Clear

End Sub

Private Sub cbotblvinID_DblClick(Cancel As Integer)

On Error GoTo ErrHandler

Dim ntblvinID As Long

If (IsNull(Me!cbotblvinID)) Then
Me!cbotblvinID.Text = ""
Else
ntblvinID = Me!cbotblvinID
Me!cbotblvinID = Null
End If

DoCmd.OpenForm "tblvin", , , , , acDialog, "New"
Me!cbotblvinID.Requery ' Get all records.

If (ntblvinID <> 0) Then
Me!cbotblvinID = ntblvinID ' Reset to original row.
End If

Exit Sub

ErrHandler:

MsgBox "Error in cbotblvinID_DblClick( ) in " & Me.Name & " form." & _
vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.description
Err.Clear

End Sub

Private Sub Form_Load()

On Error GoTo ErrHandler

If ((Me.OpenArgs = "New") And Not IsNull(Me!tblvinID)) Then
DoCmd.GoToRecord , , acNewRec
End If

Exit Sub

ErrHandler:

MsgBox "Error in Form_Load( ) in " & Me.Name & " form." & _
vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.description
Err.Clear

End Sub

Thanks in advance for your reply!
.



Relevant Pages

  • Re: Not in list combo questions
    ... Response = acDataErrContinue ... Is there a way to populate the field in the new record form ... Private Sub cbotblvinID_NotInList ... vbCrLf & vbCrLf & _ ...
    (microsoft.public.access.forms)
  • Re: OpenForm Action Cancelled
    ... >> Exit Sub ... >> When I make a selection from the combo box and then click the command ... >> command buttons just opens the Record form with all the records, ...
    (microsoft.public.access.forms)
  • Re: Event Log Query
    ... Dim gb_echo, gb_popup ... Sub s_initialize ... On Error Goto 0 ...
    (microsoft.public.scripting.vbscript)
  • RE: Tracking Log In and Log Out times of Users
    ... AuditLogger is a Sub, not a module. ... A Report module is the same, except it is specific to that report. ... A module cannot have a Sub or Function ... I have a start-up form that opens when the database opens. ...
    (microsoft.public.access.modulesdaovba)
  • Re: delete rows
    ... 'delete it in the close it will exist only for that workbook. ... Private Sub Workbook_Open ... but will be available to anyone who opens the ... Dim Rng As Range, Rng1 As Range ...
    (microsoft.public.excel.programming)