Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 18th, 2007, 04:47 AM
Authorized User
 
Join Date: Jun 2007
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default ComboBox and Get Focus

I have a sub form on my form and on that there is a ComboBox, when the ComboBox is activated the GotFocus is applied, I am trying to be able to have the options to choose in my ComboxBox selectable.

Am not sure I have explained it very well, but here is my code, any questions please ask and will try explain

Private Sub cboResponse_GotFocus()
    Dim cnn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim sQRY As String
    'On Error GoTo Err
    Set cnn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    intResponseID = Me.Recordset
    'intResponseID = Me.ResponseID
    cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;User Id=Admin; " & _
        "Data Source=" & cTables
    With Me.cboResponse
        .RowSource = _
            "SELECT tblCSATResponseType.ResponseItem " & _
            "FROM tblCSATResponseType " & _
            "WHERE tblCSATResponseType.ResponseID = " & intResponseID
    rs.CursorLocation = adUseClient
    rs.Open sQRY, cnn, adOpenForwardOnly, adLockOptimistic
    End With
End Sub

As on this code I have intResponseID = Me.Recordset then when the main form opens it shows the record in one line, I dont understand why, because this section is a set of questions and there are 5 in the table.

If I use this line which I thought might work intResponseID = Me.ResponseID I get an error on load of main form.

Jez

 
Old July 30th, 2007, 07:35 AM
Registered User
 
Join Date: Jul 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It looks like you need to reference the subform instead of using me.recordset, etc.

Dim frm as form
set frm = Forms!frmMainForm.sfrmSubform.Form
'---Code---
set frm = nothing

Then use frm instead of me.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Focus dhoward Javascript 3 September 19th, 2007 02:54 AM
Filling Combobox with value from other Combobox ayazhoda Access VBA 6 June 5th, 2007 04:58 AM
focus kvanchi General .NET 2 December 13th, 2004 09:16 PM
Focus jbenson001 ASP.NET 1.x and 2.0 Application Design 2 February 18th, 2004 02:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.