yes yes i understand.. i executed it completely new with only the requred dimensions....
better display of results
Collapse
X
-
Ah okay...
That would be pretty much the same code with the loops reversed, executed AFTER the first block...
Code:for each fld1 in rs1.fields ' Loop through import table fields for each fld in rs.fields ' Loop through MLE fields if fld1.name = fld.name then fnd = true ' We have a match! Exit, and continue to next IMPORT field varFld = fld.Name ' Save the matching field name exit for end if next ' varFld is inserted into the MLEColumnName field. If there was no match, it will appear blank.. strSQL = "INSERT INTO TEMP_Table (MLEColumnName, ImportColumnName) Values('" & VarFld & "','" & fld1.Name & "')" CurrentDb.Execute strSQL, dbFailOnError Next for each fld in rs.fields ' Loop through MLE table fields for each fld1 in rs1.fields ' Loop through Import fields if fld.name = fld1.name then fnd = true ' We have a match! Exit, and continue to next IMPORT field varFld = fld1.Name ' Save the matching field name exit for end if next ' varFld is inserted into the MLEColumnName field. If there was no match, it will appear blank.. ' ... only record unmatched this time if isNull(VarFld) = true then strSQL = "INSERT INTO TEMP_Table (MLEColumnName, ImportColumnName) Values('" & fld.Name & "','')" CurrentDb.Execute strSQL, dbFailOnError end if Next
Comment
-
I might have gone cross-eyed switching the MLE/Import loops around in that second block, so you may need to fix it up... Just a tip - when naming recordsets, especially when your code involves multiple recordsets, using names relevant to the actual data (eg: rsMLE and rsImport as opposed to rs and rs1) makes your code easier to follow.Comment
-
i understand your concept in #18.
the logic what you are doing makes sense.
but it does not seem to be working.
the 2nd column of Import table fields appears perfectly but the 1st column is completely messed up.. again some fields repeat and there are no blank spaces anywhere...
Code:MLE Import pnr pnr pnr keyword pnr Prio pnr description pnr combined tech / EFF risk risk Reason reason Justification justification Justification number MPD task already performed CSN CSN CSN MSN 3 CSN MSN 5 CSN MSN 6 CSN MSN 8 CSN MSN 10 CSN MSN 11 CSN MSN 12 CSN MSN 14 CSN MSN 13 CSN MSN 16 CSN Total FAM FAM FAM AP1 Leader FAM mutilple_in Fam FAM INC PN available FAM sales all FAM Sales SIA FAM purchase Price FAM total stock 13/11/2015 FAM C-check hit FAM % consum FAM % sales FAM average QTY consum FAM average QTY sales FAM % consum1 FAM % sales1 FAM average QTY consum1 FAM average QTY sales1 FAM % consum2 FAM % sales2 FAM average QTY consum2 FAM average QTY sales2 FAM Trend _Consumption FAM Trend_ Sales
the pattern is that the 1st column strikes a match and then it repeats that matched field name uptil it matches a new field....
pnr...risk....r eason.....
These are the matched fields not all the field names as we want it!Comment
-
my code in #11 yields this result:
Code:MLE Import matchedcolumns pnr MATCHED pnr keyword Prio description tech / EFF risk MATCHED risk Reason MATCHED reason Justification MATCHED justification number MPD task already performed CSN MATCHED CSN MSN 3 MSN 5 MSN 6 MSN 8 MSN 10 MSN 11 MSN 12 MSN 14 MSN 13 MSN 16 Total FAM MATCHED FAM AP1 Leader mutilple_in Fam INC PN available sales all Sales SIA purchase Price total stock 13/11/2015 C-check hit % consum % sales average QTY consum average QTY sales % consum1 % sales1 average QTY consum1 average QTY sales1 % consum2 % sales2 average QTY consum2 average QTY sales2 Trend _Consumption Trend_ Sales
Comment
-
great!! I think I just hit Gold...
I slightly modified your #18 answer and now i think it Looks great..
I added an ELSE condition to your code.
Code:For Each fld1 In rsIMP.Fields For Each fld In rsMLE.Fields If fld1.Name = fld.Name Then fnd = True varFld = fld.Name match = "MATCHED" Exit For Else: varFld = " " match = " UNMATCHED IMPORT FIELDS" End If Next strSQL = "INSERT INTO TEMP_Table (MLEColumnName, ImportColumnName, matchedcolumns) Values('" & varFld & "','" & fld1.Name & "', '" & match & "')" CurrentDb.Execute strSQL, dbFailOnError Next For Each fld In rsMLE.Fields For Each fld1 In rsIMP.Fields If fld.Name = fld1.Name Then fnd = True varFld = fld1.Name Exit For Else: varFld = " UNMATCHED TARGET FIELDS " End If Next If varFld = " UNMATCHED TARGET FIELDS " Then strSQL = "INSERT INTO TEMP_Table (MLEColumnName, matchedcolumns) Values('" & fld.Name & "','" & varFld & "')" CurrentDb.Execute strSQL, dbFailOnError End If Next
I would have liked to have them simulatneously side by side so that the user does not have to scroll down but i guess this is also ok..
is it possible to Change the FONT Color of the cell in an IF Statement??
like IF the cell has this value Change Color to green..
never done it before.Comment
-
ok.. most Problems solved.. last step....
now i have a subform in a form which is a popup form.
this subform has the table connected to it.
i did conditional formatting to the subform..
but this formatting dissapears when i open the popup form..
i guess i have to activate or something??Comment
-
<<< is it possible to Change the FONT Color of the cell in an IF Statement??
like IF the cell has this value Change Color to green..>>>
Did you work out how to use "Expression IS" formatting in the conditional formatting popup.
<<
i did conditional formatting to the subform..
but this formatting dissapears when i open the popup form..
>>
Have you resolved this? Conditional formatting *should* work fine in a popup form. If this is still an issue, post another question specifically describing the Conditional Formatting issue -- with details including the Conditional Formatting rules you are using, and situations where it works or fails.Comment
-
its so annoying that after getting the code to do all what i want but finally this last step stops me... i do the formatting using conditional formatting and it works fine on a subform, i just dont know where it dissapears to when i open the parent form. anyways as you said i will ask it as a seperate question...
thanks a lot mbizup.. the code i had orginally was a Long one which took me so much effort.. you surprised me with a short and compact code.. thanks a lot!!!!
as you said, feels really great!!!Comment
Comment