Re: Some help, please with code
- From: mtrimpin24 <mtrimpin24@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 19 Nov 2007 04:57:01 -0800
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
- Follow-Ups:
- Re: Some help, please with code
- From: Wolfgang Kais
- Re: Some help, please with code
- References:
- Re: Some help, please with code
- From: Wolfgang Kais
- Re: Some help, please with code
- Prev by Date: Re: Some help, please with code
- Next by Date: Auto populate form fields from table
- Previous by thread: Re: Some help, please with code
- Next by thread: Re: Some help, please with code
- Index(es):
Relevant Pages
|