Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Location
    Watford, UK
    Posts
    2

    Unanswered: Pocket Access - AddNew

    Hi

    I am having a problem with Pocket Access.

    Hi

    I have managed to select a single row within a table.
    Is it possible to select a single row within table A
    and then update table B with the records.

    I want to avoid the user typing in the data e.g.:
    'Get user input
    FirstName = InputBox("Enter a First Name", "Edit")

    'Edit the current record
    RS("FirstName") = FirstName

    I want the user to only enter a single value, then all the selected data from Table A inserted into table B.

    I keep getting Application error:
    The application is using arguments of the wrong type..bblah...

    This is the code:
    Private Sub Test_Click()
    Dim RS2 As ADOCE.Recordset
    Dim SQL As String
    Dim InputText As String
    Dim MyVar As String
    Set RS2 = CreateObject("ADOCE.Recordset.3.1")

    RS2.Open Test, "\My Documents\Housing.cdb"

    ' UPDATE test INNER JOIN HousingEstates ON (test.BlockName = HousingEstates.Block)
    ' AND (test.ContractArea = HousingEstates.ContractArea) SET;

    'SQL = "SELECT * FROM ContractAreas INNER JOIN HousingEstates"
    'SQL = SQL & " ON ContractAreas.ContractArea = HousingEstates.ContractArea"
    'SQL = SQL & " WHERE ContractAreas.ContractArea = 2"
    'RS("Blockname") = Block

    MyVar = "Scott Court"
    MsgBox (MyVar)

    SQL = "SELECT * FROM HousingEstates "
    SQL = SQL & " WHERE HousingEstates.Block = '" & MyVar & "'" 'Scott House'"


    Block = SQL
    RS2.AddNew
    RS("BlockName") = Block

    Dim ifield As Integer
    For ifield = 0 To RS.Fields.Count - 1
    RS2.Fields(ifield).Value = RS.Fields(ifield).Value
    Next

    RS2.Update
    End Sub


    ANY assistance would be appreciated.

    Cheers
    Clive

  2. #2
    Join Date
    Dec 2003
    Location
    Toronto, Ont. Canada
    Posts
    238

    Re: Pocket Access - AddNew

    Hi Clive...

    A couple of questions... Where are RS and Block declared? .... I don't see that anywhere in your code... Have you stepped through the code to see exactly what line is giving you trouble?

  3. #3
    Join Date
    Dec 2003
    Location
    Watford, UK
    Posts
    2

    AddNew

    HI Trudi

    I am running this on a Pocket PC NOT on a PC.

    Didn't include all the code for space:

    Private Sub Test_Click()
    Dim RS2 As ADOCE.Recordset
    Dim SQL As String
    Dim InputText As String
    Dim ColumnNames As String
    Dim ColumnValues As String
    Dim ParamName As String
    Dim MyVar As String
    Set RS2 = CreateObject("ADOCE.Recordset.3.1")

    RS2.Open Test, "\My Documents\Housing.cdb"

    ' UPDATE test INNER JOIN HousingEstates ON (test.BlockName = HousingEstates.Block)
    ' AND (test.ContractArea = HousingEstates.ContractArea) SET;

    'SQL = "SELECT * FROM ContractAreas INNER JOIN HousingEstates"
    'SQL = SQL & " ON ContractAreas.ContractArea = HousingEstates.ContractArea"
    'SQL = SQL & " WHERE ContractAreas.ContractArea = 2"
    'RS("Blockname") = Block

    MyVar = "Scott Court"
    MsgBox (MyVar)

    SQL = "SELECT * FROM HousingEstates "
    SQL = SQL & " WHERE HousingEstates.Block = '" & MyVar & "'" 'Scott House'"


    Block = SQL
    RS2.AddNew
    RS("BlockName") = Block

    Dim ifield As Integer
    For ifield = 0 To RS.Fields.Count - 1
    RS2.Fields(ifield).Value = RS.Fields(ifield).Value
    Next

    RS2.Update

    'Remove existing data from grid
    For i = 1 To GridCtrl1.Rows
    GridCtrl1.RemoveItem 0
    Next

    'Set the Grid columns equal to the field count
    GridCtrl1.Cols = RS.Fields.Count

    'Get the column names
    For i = 0 To RS2.Fields.Count - 1
    ColumnNames = ColumnNames & RS2.Fields(i).Name & vbTab
    Next

    'Add the column headers to the grid
    GridCtrl1.AddItem ColumnNames

    'Loop through the recordset
    While Not RS.EOF

    'Get the column values for this row
    For i = 0 To RS2.Fields.Count - 1
    ColumnValues = ColumnValues & RS2.Fields(i).Value & vbTab
    Next

    'Add the column values to the row
    GridCtrl1.AddItem ColumnValues

    'Set ColumnValues to a zero length string
    'so it can be refilled with the next row
    ColumnValues = ""

    RS.MoveNext
    Wend

    'Close and dereference the Recordset
    RS2.Close
    Set RS2 = Nothing



    End Sub

  4. #4
    Join Date
    Dec 2003
    Location
    Toronto, Ont. Canada
    Posts
    238

    Re: AddNew

    Clive...

    Okay... I have to admit I've never developed anything for a Pocket PC yet so I'm no expert on this one... So are you actually developing the app on the Pocket PC itself? and does that mean that you don't have the option of stepping through the code that you write?

    As for the RS and Block variables I asked about... I still don't see any declarations for them in the expanded code... The code doesn't have a Set statement anywhere for your RS variable... If you're declaring a second Recordset object (I see you using RS.Movenext) then I'm pretty sure you're going to need to declare it as such and use a SET statement to allocate it some memory...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •