Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

ms Access VBA using a string from another form?

I have a form called RetailEntry that has two columns I'm attempted to use as a string for when my users hit a Review button built into a separate form that pops up.

The following is a very simplified version of my code:

Private Sub ReviewButton_Click()
Dim strSeason As String
Dim strType As String

Set db = CurrentDb

strSeason = Forms!RetailEntry.Season.Value
strType = Forms!RetailEntry.Offer.Value
End Sub

When I click my review button I keep getting the error message "Invalid Use of Null" on my strings strSeason = Forms!RetailEntry.Season.Value strType = Forms!RetailEntry.Offer.Value but it shouldn't be seeing a null/blank as these are fields that are filled out in the form RetailEntry.

What happens next in the code (the part you don't see) is a string that setups up a SQL query uses the strSeason, and strType based on what was entered in the RetailEntry form under the corresponding fields.

I'm thinking it has to do with the fact that my Review button is it's own form but I'm not sure. Any help would be greatly appreciated.

Thanks!

question from:https://stackoverflow.com/questions/65892570/ms-access-vba-using-a-string-from-another-form

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I resolved it with the following lines:

strSeason = [Forms]![ReviewButton]![RetailEntry].[Form]![Season].Value
strType = [Forms]![ReviewButton]![RetailEntry].[Form]![Offer].Value

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...