Results 1 to 6 of 6
  1. #1
    rashima is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    16

    form wizard but data is from sql server

    So I have access form and my backend is sql server, i want to display sqlserver table data on this form...........same way form wizard works with access tables
    how can i do this ?

    i can get recordset from sql server and assign values individually to each control but i want to get this table data on my form as tabular format

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Maybe set form DefaultView property to Datasheet view?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    rashima is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    16
    text in red color is not working, giving error "the object you entered is not a valid recordset property" please helppp

    Private Sub Form_Load()
    Dim RunSelect6Cmd As New ADODB.Command
    Dim rsOutputList As New ADODB.Recordset
    Dim sLBList As String
    InitCommand RunSelect6Cmd, "select * from tbl_Detail"
    Set rsOutputList = ExecuteCommand(RunSelect6Cmd)
    Debug.Print rsOutputList.Fields("User_ID")
    Set Me.Recordset = rsOutputList
    end sub

    Sub InitCommand(ByVal Cmd As ADODB.Command, cmdText)
    With Cmd
    .ActiveConnection = MyConnectionString
    .CommandText = cmdText
    .Prepared = True
    End With
    End Sub
    Function ExecuteCommand(ByVal Cmd As ADODB.Command, ParamArray values() As Variant) As ADODB.Recordset
    Dim i As Long
    Dim s As String

    For i = LBound(values) To UBound(values)
    Cmd.Parameters(i - LBound(values)).Value = values(i)
    Next i
    Set ExecuteCommand = Cmd.Execute
    End Function

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    I think wrong syntax. Don't believe can set a form's RecordSet, set it's RecordSource property to an SQL statement, not a retrieved recordset. Do you have links to the SQL tables?

    Private Sub Form_Load()
    Me.RecordSource = "select * from tbl_Detail;"
    End Sub

    But then I have never tried working with a SQL backend.

    The Debug statement will print UserID of only the first record of the recordset.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    rashima is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    16
    I Don't want to work with link tables so my back end is on sql-server and i am working with ADO.
    now i figure out that this below is working but not the one i posted above but i don't know whats the main difference between these 2 codes


    sSQL = "SELECT * from View_Detail"
    conMyConnection.ConnectionString = MyConnectionString
    conMyConnection.Open
    rsOutputList.Open sSQL, conMyConnection, adOpenStatic, adLockPessimistic
    Set Me.Recordset = rsOutputList

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Glad it's working. The difference appears to be the sequence in establishing connection.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 04-13-2012, 01:45 PM
  2. Accessing Data Import wizard via a macro?
    By Madraykin in forum Import/Export Data
    Replies: 6
    Last Post: 03-27-2012, 12:34 PM
  3. Data access pages and SQL Server
    By jfloan in forum Access
    Replies: 0
    Last Post: 03-19-2012, 01:39 PM
  4. How to add multipage after using form wizard?
    By robertrobert905 in forum Access
    Replies: 1
    Last Post: 09-21-2010, 02:37 PM
  5. Using Import wizard to get Excel data
    By Jack Sheet in forum Import/Export Data
    Replies: 5
    Last Post: 07-16-2010, 09:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums