Error Message

T

Toco Hara

Hello. I receive this error message when I try to open a
second form that receives data from first form:

Run Time Error; The field is too small to accept the
amount of data you attempted to add.

Code Executed during OnClick on first form:
Dim strDocName As String
Dim strLinkCriteria As String

strDocName = "frmOrders" 'second form

strLinkCriteria = "[DtOrdered]=" & "#" & Me![DtOrdered]
& "#" & " AND"
[CustomerNumber] = " & " & Me![CustomerNumber] & "'"


DoCmd.OpenForm strDocName, , , strLinkCriteria

DtOrdered and CustomerNumber make up primary keys in the
underlying orders table and customers table. One form
uses Orders table, and other uses customer table. Passing
values between forms is not working. Any suggestions.
Thank you much
 
J

John Vinson

strLinkCriteria = "[DtOrdered]=" & "#" & Me![DtOrdered]
& "#" & " AND"
[CustomerNumber] = " & " & Me![CustomerNumber] & "'"

I think you're missing a quote, and missing a blank after the word
AND. If CustomerNumber is a Text field you need a ' both before and
after. Also, you don't need to use so many little string constants -
the strLinkCriteria should end up as a single String, constructed by
concatenating constant portions and variable portions; but you don't
need "#" as a separate string. Try:

strLinkCriteria = "[DtOrdered] = #" & Me!DtOrdered _
& "# AND [CustomerNumber] = '" & Me![CustomerNumber] & "'"

Your expression would have built

[DtOrdered]=#7/14/2003# AND[CustomerNumber] = 123'

The revision will build

[DtOrdered] = #7/14/2003# AND [CustomerNumber] = '123'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top