VBA Code gone wrong

LiquidMetal

New member
Local time
Today, 13:28
Joined
Dec 4, 2012
Messages
5
Hi All

I am new and learning.

Please help me with this code:

MsgBox "Please Click Once Only"
If ("CostTypeID", "qryCompLensPrices", "PMDID='tblPMDP.PMDID'") = ("CostTypeID", "tblPMDP", "PMDID") Then
MsgBox "The Total Price has been Calculated"
Else
DoCmd.OpenQuery "qryAddCompCosts"
End If


I am trying to limit the number of times a query is run if costtypeid and PMDID in the query is equal to the same data in the storing table called tblPMDID.

Thanks for your help. Using Access 2010.
 
Does the If condition include a Domain function like DLookUp or DCount??
 
Does the If condition include a Domain function like DLookUp or DCount??


I am sorry I am a total noob at this.

I saw this on the net and wanted to modify it for my own use.

I have tried looking at if else statments but have not got very far.

If I can explain what I want to do:

I want to insert two values into a tble called tblPMDP

I have an append query but append queries cannot be used in vba so I have an identical select query called qryCompLensPrices.

I want to compare two values in qryCompLensPrices with the table.

if both values are equal then do nothing,

if PMDID on the table side is null add values
 
Okay what is PMDID's Data Type??? ID sounds like Number but you have wrapped in Single quotes.??

Also VBA can be used to Append (INSERT) into tables, not via Queries, you will construct the queries on the fly.. But anyway.. Could you give some sample data? with the sample data could you explain your problem a bit more.
 
Okay what is PMDID's Data Type??? ID sounds like Number but you have wrapped in Single quotes.??

Also VBA can be used to Append (INSERT) into tables, not via Queries, you will construct the queries on the fly.. But anyway.. Could you give some sample data? with the sample data could you explain your problem a bit more.


The table tblPMDP is:

PMDPID - PK
PMID - FK
CostTypeID (Number)
ProcessPrice Currency

some data:

PMDID - 1, 2, 3, 4, 5, each refers to everytime the form is used to create a price quote.

for every costypeID (There are 19 only) 1-19 selected by the user it refers to the PMDID

so

PMDID CostTypeID Cost
1 1 2.56
1 3 1.25
1 7 12.22
1 9 0.68

etc

I have been learning on the fly and need to produce results, the append is used to insert prices for costs that are compulsory and hence not shown to the user but is added via the append query.

If the append query is run again - it insert the same values again.

Hope this is clearer.
 
Hello Sorry I had so much work to do in the last couple of days I could hardly come online.. I am finding it hard to follow what you want to do.. Could you please have another shot at explaining??
 

Users who are viewing this thread

Back
Top Bottom