pdvsa
asked on
Update Qry
Experts,
I have a tblLetterOfCredit and it has some blank fields.
I need to update those blank fields based on another table I imported from Excel [tblExcelImport].
I can match between the two table on LCNo.
I think there are two ways to do this: canned update qry in MSAccess or by code
~~~~~~~~~~~
Maybe it is easier to see In code (it would be something like this):
If [tblLetterofCredit][LCNo] matches [tblExcelImport][LCNo] then update APPLICANT on tblLetterOfCredit from [Applicant] in the excel file BUT ONLY IF LCNO UNDER TBLLETTEROFCREDIT IS BLANK.
I hope my explanation is clear enough and please ask if you have questions.
I have a tblLetterOfCredit and it has some blank fields.
I need to update those blank fields based on another table I imported from Excel [tblExcelImport].
I can match between the two table on LCNo.
I think there are two ways to do this: canned update qry in MSAccess or by code
~~~~~~~~~~~
Maybe it is easier to see In code (it would be something like this):
If [tblLetterofCredit][LCNo] matches [tblExcelImport][LCNo] then update APPLICANT on tblLetterOfCredit from [Applicant] in the excel file BUT ONLY IF LCNO UNDER TBLLETTEROFCREDIT IS BLANK.
I hope my explanation is clear enough and please ask if you have questions.
ASKER
OH YES...that is right I did mean Applicant. Thanks for that. Let me test it. I did not include all and so I need to use what you said and modify it a little.
ASKER
I get an error of "type conversion failure. I wonder if this could be becuase the field I am trying to update is a combobox ([tblLetterofCredit].APPLI CANT). I remember now that I tried doing this before and ran into the same issue.
What do you think?
untitled.JPG
What do you think?
untitled.JPG
Is Applicant the only field that is being updated?
Please list the fields and types being updated to/from on both tables.
I think you need a conversion somewhere.
Please list the fields and types being updated to/from on both tables.
I think you need a conversion somewhere.
ASKER
Yes, Applicant is the only field being updated. The property is Number with a row source qry in it on tblLetterOfCredit. It is acombobox.
On tblExcelImport, applicant is text.
(doing this from memory). Pretty sure it is correct.
Any ideas? Thanks
On tblExcelImport, applicant is text.
(doing this from memory). Pretty sure it is correct.
Any ideas? Thanks
The source from tblExcelImport may have invalid number, or some fields that are blank strings.
You can try this
update [tblLetterofCredit],[tblEx celImport]
set [tblLetterofCredit].APPLIC ANT = [tblExcelImport].APPLICANT
where nz([tblLetterofCredit].APP LICANT,"") = ""
AND [tblLetterofCredit].[LCNo] = [tblExcelImport].[LCNo]
AND val("0" & [tblExcelImport].APPLICANT ) <> 0
It will omit all the invalid tblExcelImport.Applicant values
You can try this
update [tblLetterofCredit],[tblEx
set [tblLetterofCredit].APPLIC
where nz([tblLetterofCredit].APP
AND [tblLetterofCredit].[LCNo]
AND val("0" & [tblExcelImport].APPLICANT
It will omit all the invalid tblExcelImport.Applicant values
ASKER
will try to get to this today....thx...
ASKER
cyberkiwi: how could I modify it to update where LCNo = LCNo from both tables?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
set [tblLetterofCredit].APPLIC
where nz([tblLetterofCredit].APP
AND [tblLetterofCredit].[LCNo]
I think you mean
BUT ONLY IF __APPLICANT__ UNDER TBLLETTEROFCREDIT IS BLANK.