Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
877 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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...