Re: Some help, please with code

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



All right. i'm going to reply to Wolfgangs. -- the other code is essentially
correct, though you were right the first time. "Random" is the name of the
table i'm important, and the work/temp table that the user creates on
importing the spreadsheet. Table append has a different query attached to
it, that isn't involved here, and sorts the data and performs some other
functions.

-- when i run this code, after putting it on the correct lines because of
weird carriage returns in this posting thing, and run it i get a msg box and
a field asking for the table name -- Exactly what i wanted. After typing in
the table name though,
i'm getting "Too foo parameteres. Expected 3." it doesn't give a line
number or highlight the area of "wrongness" in the visual basic mini-app
though.
What have i done wrong?

"Wolfgang Kais" wrote:

Hello "mtrimpin24".

"mtrimpin24" wrote:
Would someone please help me turn the following psuedo code into
visual basic? It involves two tables. One table will be imported
and named by the person using the form. The other table is named
Tableappend and it has a query attached to it to do its thing.
The involved fields on the table, that will be used during this
code's runtime are:
Random.postedamount
Random.reportname
Random.sapcompanycode

The code should do two passes, each loop looking for a specific
set of information. In order to build tableappend with the proper
records.

The user imports a spreadsheet from excel, and creates a table
with the spreadsheet. Some of the records are being discarded.
It should go something like this:

Button press
{
deleteallrecordsfromtableappend( )
gettablenamefromuser( )
opentable( )
for(int counter = 0;counter<=.recordcount;counter++)
{
if random.currentrecord.postedamount>=$3500.00
appendrecord(Tableappend)
else if (random.currentrecord.sapcompanycode == 110 or 118 or 185
or 514
&& random.currentrecord.postedamount>=$1500.00 then
appendrecord(Tableappend)

random.nextrecord
}

for(int counter2 = 0;counter2 <=.recordcount;counter2++)
{

if(random.currentrecord.postedamount >= $3500.00 OR
(random.currentrecord.sapcompanycode == 110 or 118 or 185 or 514 &&
random.currentrecord.postedamount >=$1500.00) OR
random.currentrecord.reportname == "mileage" "mile" "mlg")
then next record;
else appendrecord(tableappend);
counter2+10;
}

help, pretty please :( i've written this in c++ psuedocode.
if anyone has trouble understanding it, please ask. i really need
help with this.

Here's what I did (using InputBox to get the table name):

Private Sub Button_Click()
On Error GoTo Err_Button_Click

Dim strTable As String, strCriteria As String
Dim strInsert As String, strSelect As String, strSQL As String
Dim rstAppend As DAO.Recordset

strInsert = _
"INSERT INTO TableAppend (postedamount,reportname,sapcompanycode) "
strSelect = "SELECT postedamount,reportname,sapcompanycode FROM "
strCriteria = _
"(postedamount>=3500) Or " & _
"(sapcompanycode IN (110,118,185,514) And postedamount>=1500)"

With CurrentDb
.Execute "DELETE FROM tableappend"
strTable = InputBox("Enter the table name", "process table")

strSQL = strInsert & strSelect & strTable & _
" WHERE " & strCriteria
.Execute strSQL
strCriteria = "NOT (" & strCriteria & _
" Or (reportname IN ('mileage','mile','mlg')))"
strSQL = strSelect & strTable & " WHERE " & strCriteria
Set rstAppend = .OpenRecordset("TableAppend", dbOpenDynaset,
dbAppendOnly)
With .OpenRecordset(strSQL, dbOpenDynaset)
Do Until .EOF
rstAppend.AddNew
rstAppend!postedamount = !postedamount
rstAppend!reportname = !reportname
rstAppend!sapcompanycode = !sapcompanycode
rstAppend.Update
.Move 10
Loop
.Close
rstAppend.Close
End With
Set rstAppend = Nothing
End With

Exit_Button_Click:
Exit Sub

Err_Button_Click:
MsgBox Err.Description, vbExclamation
Resume Exit_Button_Click

End Sub

--
Regards,
Wolfgang



.



Relevant Pages

  • Re: Some help, please with code
    ... Tableappend and it has a query attached to it to do its thing. ... The user imports a spreadsheet from excel, ... Dim strTable As String, strCriteria As String ... Set rstAppend = .OpenRecordset("TableAppend", dbOpenDynaset, ...
    (microsoft.public.access.formscoding)
  • Re: aus VBA bestimmtes Verzeichnis anzeigen
    ... Wolfgang Thienel ... also nicht das Stammverzeichis ändern und auch nicht ... > lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As ...
    (microsoft.public.de.excel)
  • Re: First Major Guitar Tech Job
    ... You don't have to string it backwards, you just cut off the ball end. ... It's a good thing you brought a reliable guitar for him to use. ... mean you had 10s on the LP, and 9s on the Wolfgang, or did you string up ... cause havoc with a floating bridge. ...
    (alt.guitar)
  • Re: 64 bit IEEE nach double
    ... Hallo Michaela, ... > Wolfgang Bornatowicz wrote: ... > Der modbus sendet dir die daten in der "falschen" Reihenfolge. ... > Wenn Du diesen String umdrehst, abspeicherst, als binary öffnest und einen ...
    (microsoft.public.de.vb)
  • Re: Multiple Filters in a Form
    ... I am not sure how to set a string to null other than ... On viewing the filter grid / SQL via Records, Filters, Advanced ... "Wolfgang Kais" wrote: ... Dim strWhere As String ...
    (microsoft.public.access.forms)