Access 2010에서 백엔드 JET 데이터베이스로 작업하고 해당 데이터베이스에 값을 삽입합니다.Access 데이터베이스에서 VBA를 사용하여 특정 값의 삽입을 허용하지 않습니다.
이 (오류 MSG가 반환)
insert into [PROJECT RESOURCE UPDATE HISTORY] ([Current Date], [Project Auto No Ref], [Resource ID Ref], [Allocation Notes], [Allocation Role],[Usage Percentage - Oct], [Usage Percentage - Nov], [Usage Percentage - Dec], [Usage Percentage - Jan], [Usage Percentage - Feb], [Usage Percentage - Mar], [Usage Percentage - Apr], [Usage Percentage - May],[Usage Percentage - Jun], [Usage Percentage - Jul], [Usage Percentage - Aug], [Usage Percentage - Sep]) values (#2/13/2017 11:01:41 AM#, 540,11,'','Project Manager',0,1,1,1,1,1,1,0,0,0,0,0)
를 데이터베이스에 삽입하지 않습니다하지만이
insert into [PROJECT RESOURCE UPDATE HISTORY] ([Current Date], [Project Auto No Ref], [Resource ID Ref], [Allocation Notes], [Allocation Role],[Usage Percentage - Oct], [Usage Percentage - Nov], [Usage Percentage - Dec], [Usage Percentage - Jan], [Usage Percentage - Feb], [Usage Percentage - Mar], [Usage Percentage - Apr], [Usage Percentage - May],[Usage Percentage - Jun], [Usage Percentage - Jul], [Usage Percentage - Aug], [Usage Percentage - Sep]) values (#2/13/2017 11:04:38 AM#, 540,821,'','DevOps',0,0.13,0.13,0.13,0.13,0.13,0.13,0,0,0,0,0)
을 수행하고 여기에 삽입 실제를 수행하는 코드의 조각이
sqlStatement2 = "insert into [PROJECT RESOURCE UPDATE HISTORY] (" & _ "[Current Date], [Project Auto No Ref], [Resource ID Ref], [Allocation Notes], [Allocation Role]," & _ "[Usage Percentage - Oct], [Usage Percentage - Nov], [Usage Percentage - Dec], [Usage Percentage - Jan]," & _ "[Usage Percentage - Feb], [Usage Percentage - Mar], [Usage Percentage - Apr], [Usage Percentage - May]," & _ "[Usage Percentage - Jun], [Usage Percentage - Jul], [Usage Percentage - Aug], [Usage Percentage - Sep] " & _ ") values (" & _ "#" & Now() & "#," & _ rst![Current Project Ref No] & "," & rst![Current Resource Person ID] & ",'" & rst![Current Allocation Notes] & _ "','" & rst![Current Allocation Role] & "'," & CDbl(oct) & "," & CDbl(nov) & "," & CDbl(dec) & _ "," & CDbl(jan) & "," & CDbl(feb) & "," & CDbl(mar) & "," & CDbl(apr) & _ "," & CDbl(may) & "," & CDbl(jun) & "," & CDbl(jul) & "," & CDbl(aug) & _ "," & CDbl(sep) & ");" MsgBox (sqlStatement2) CurrentDb.Execute (sqlStatement2) rst.MoveNext
첫 번째 예제에서 데이터베이스에 1을 삽입하는 문제가 있다고 생각합니다. 데이터베이스가 오류를보고하지 않고 행이 나타나지 않습니다. 값을 1에서 0.99로 변경하면 데이터베이스에 잘 삽입되어 표시됩니다. 내가 시도 것들과 관찰 :
또한 수동으로 내 VBA 코드에 삽입 문을 수행하기 전에 CDbl에는() 함수를 사용하여 이중에 하나를 변환하기 위해 노력했다. 내가 값을 1로 처음 삽입 한 후 코드를 중단하는 경우
, 행과 같은 다음 값으로 행 ID 건너 뛰는
내가 다른 볼 수
를 삽입?
나는 1.0 값을 하드 코딩하면 효과가있을 것이다. 지역 설정은 무엇입니까? 1,1,1을 숫자로 해석하는지 궁금합니다. – Minty
* "데이터베이스에서 오류를보고하지 않습니다."* - 'CurrentDb.Execute sqlStatement2, dbFailOnError'를 사용하여 다른 방식으로 동작하는지 확인하십시오. –
@gordThompson dbFailOnError를 사용하여 테이블 자체에 대한 유효성 검사 오류가 있음을 발견했습니다. 감사! – Tino