Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8662893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:50:43+00:00 2026-06-12T16:50:43+00:00

But I am sure that the data types can work together, ItemID from 1

  • 0

But I am sure that the data types can work together, ItemID from 1 table is AutoNumber and a number in the other table.

Private Sub Command17_Click()

Dim cmbItem As String

cmbItem = "SELECT ItemID FROM Items WHERE Items.Name = " & Me.Combo0.Value & ";"

Dim sc1 As DAO.Recordset
Set sc1 = CurrentDb.OpenRecordset("Buy", dbOpenDynaset)

sc1.AddNew
sc1.Fields("ItemID").Value = cmbItem
sc1.Fields("BuyPrice").Value = Me.Text13.Value
sc1.Fields("Notes").Value = Me.Text18.Value
sc1.Update

End Sub

Thanks in advance,
Bob P

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:50:44+00:00Added an answer on June 12, 2026 at 4:50 pm

    If this is the line which triggers your error …

    sc1.Fields("ItemID").Value = cmbItem
    

    … notice that cmbItem is a string which contains a SELECT statment (SELECT ItemID FROM ...). And you told us “ItemID from 1 table is AutoNumber and a number in the other table“. So you’re attempting to assign a string value to a numeric field. Furthermore, that string can’t be cast to a valid number. It has to fail.

    Just guessing here, but maybe you want something like this …

    Dim cmbItem As Long
    cmbItem = DLookup("ItemID", "Items", "[Name]=" & Me.Combo0.Value)
    

    If [Name] is a text field, add quotes around the value you compare it to …

    cmbItem = DLookup("ItemID", "Items", "[Name]='" & Me.Combo0.Value & "'")
    

    If that’s close, you could rename the variable to lngItem so the code is less likely to confuse your collaborators.

    If the DLookup() might return Null, consider feeding it to a Nz() expression.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure that title is worded very well, but not sure how else
I am not sure where i've seen this before, but im sure that there
I may be missing something, but I'm sure that I've checked everything, I forked
I was sure that it hasn't, but looking for a definite answer on the
I am sure that this kind of questions must have been asked before, but
I'm 99% sure that the answer is no, but I'm wondering if someone who
I see this question here on SO but I am not sure that answers
I have a simple question, but I'm about 80% sure that the answer to
I'm tring to use com.google.android.apps.analytics.GoogleAnalyticsTracker but got NoClassDefFoundError when GoogleAnalyticsTracker.getInstance(); I'm sure that libGoogleAnalytics.jar
I'm not sure if that is possible in C# but I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.